Debian Codegraph @

tests/phpunit/mocks/json/ManagedObject.php

raw symbols SCIP
1 <?php
2 namespace MediaWiki\Tests\Json;
3
4 use Psr\Container\ContainerInterface;
5 use Wikimedia\JsonCodec\JsonClassCodec;
6 use Wikimedia\JsonCodec\JsonCodecable;
7 use Wikimedia\JsonCodec\JsonCodecInterface;
8
9 /**
10 * Managed object which uses a factory in a service.
11 */
12 class ManagedObject implements JsonCodecable {
13
14 /** @var string */
15 public string $name;
16 /** @var int */
17 public int $data;
18
19 /**
20 * Create a new ManagedObject which stores $property. This constructor
21 * shouldn't be invoked directly by anyone except ManagedObjectFactory.
22 *
23 * @param string $name
24 * @param int $data
25 * @internal
26 */
27 public function __construct( string $name, int $data ) {
28 $this->name = $name;
29 $this->data = $data;
30 }
31
32 // Implement JsonCodecable by delegating serialization/deserialization
33 // to the 'ManagedObjectFactory' service.
34
35 /** @inheritDoc */
36 public static function jsonClassCodec(
37 JsonCodecInterface $codec, ContainerInterface $serviceContainer
38 ): JsonClassCodec {
39 return $serviceContainer->get( 'ManagedObjectFactory' );
40 }
41 }