Localisation updates from https://translatewiki.net.
[mediawiki.git] / tests / phpunit / mocks / json / ManagedObject.php
blob45f2638bf427264ac073f80418ea3bf8ded0c326
1 <?php
2 namespace MediaWiki\Tests\Json;
4 use Psr\Container\ContainerInterface;
5 use Wikimedia\JsonCodec\JsonClassCodec;
6 use Wikimedia\JsonCodec\JsonCodecable;
7 use Wikimedia\JsonCodec\JsonCodecInterface;
9 /**
10 * Managed object which uses a factory in a service.
12 class ManagedObject implements JsonCodecable {
14 /** @var string */
15 public string $name;
16 /** @var int */
17 public int $data;
19 /**
20 * Create a new ManagedObject which stores $property. This constructor
21 * shouldn't be invoked directly by anyone except ManagedObjectFactory.
23 * @param string $name
24 * @param int $data
25 * @internal
27 public function __construct( string $name, int $data ) {
28 $this->name = $name;
29 $this->data = $data;
32 // Implement JsonCodecable by delegating serialization/deserialization
33 // to the 'ManagedObjectFactory' service.
35 /** @inheritDoc */
36 public static function jsonClassCodec(
37 JsonCodecInterface $codec, ContainerInterface $serviceContainer
38 ): JsonClassCodec {
39 return $serviceContainer->get( 'ManagedObjectFactory' );