Skip to content

Commit 53387a4

Browse files
manickiWMDE bot
authored andcommitted
Dropped "repository name" and "local part" from EntityId
Bug: T291823 Depends-On: I13e3c1a238459dd26ba2e613d78eb7b87bb35533 Depends-On: I7bb37487c706afe8244129472bd35cf536eca62a Change-Id: Ie9661c0e89d03afc28845e374f24dbed22cdee74
1 parent 15dd08b commit 53387a4

6 files changed

Lines changed: 0 additions & 84 deletions

File tree

src/Entity/EntityId.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,6 @@ public function __toString();
3232
*/
3333
public function equals( $target );
3434

35-
/**
36-
* TODO: This method shouldn't exist on this interface as it doesn't make sense for certain types of IDs. It should be moved to a
37-
* separate interface, or removed altogether.
38-
*
39-
* @return string
40-
*/
41-
public function getLocalPart();
42-
43-
/**
44-
* TODO: This method shouldn't exist on this interface as it doesn't make sense for certain types of IDs. It should be moved to a
45-
* separate interface, or removed altogether.
46-
*
47-
* @return string
48-
*/
49-
public function getRepositoryName();
50-
5135
/**
5236
* This method replaces {@link Serializable::serialize()}.
5337
* Do not call it manually.

src/Entity/ItemId.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ public function serialize() {
7676

7777
public function __unserialize( array $data ): void {
7878
$this->serialization = $data['serialization'];
79-
list( $this->repositoryName, $this->localPart ) =
80-
self::extractRepositoryNameAndLocalPart( $this->serialization );
8179
}
8280

8381
/**
@@ -89,8 +87,6 @@ public function unserialize( $serialized ) {
8987
$array = json_decode( $serialized );
9088
$this->serialization = is_array( $array ) ? $array[1] : $serialized;
9189
$this->serialization = $this->serialization ?? '';
92-
list( $this->repositoryName, $this->localPart ) =
93-
self::extractRepositoryNameAndLocalPart( $this->serialization );
9490
}
9591

9692
/**

src/Entity/NumericPropertyId.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ public function serialize() {
7070

7171
public function __unserialize( array $data ): void {
7272
$this->serialization = $data['serialization'];
73-
list( $this->repositoryName, $this->localPart ) =
74-
self::extractRepositoryNameAndLocalPart( $this->serialization );
7573
}
7674

7775
/**
@@ -83,8 +81,6 @@ public function unserialize( $serialized ) {
8381
$array = json_decode( $serialized );
8482
$this->serialization = is_array( $array ) ? $array[1] : $serialized;
8583
$this->serialization = $this->serialization ?? '';
86-
list( $this->repositoryName, $this->localPart ) =
87-
self::extractRepositoryNameAndLocalPart( $this->serialization );
8884
}
8985

9086
/**

src/Entity/SerializableEntityId.php

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,6 @@ abstract class SerializableEntityId implements EntityId {
1212

1313
protected $serialization;
1414

15-
/**
16-
* @var string
17-
*/
18-
protected $repositoryName;
19-
20-
/**
21-
* @var string
22-
*/
23-
protected $localPart;
24-
2515
public const PATTERN = '/^[^:]+\z/';
2616

2717
/**
@@ -32,8 +22,6 @@ abstract class SerializableEntityId implements EntityId {
3222
public function __construct( $serialization ) {
3323
self::assertValidSerialization( $serialization );
3424
$this->serialization = self::normalizeIdSerialization( $serialization );
35-
36-
list( $this->repositoryName, $this->localPart ) = self::extractRepositoryNameAndLocalPart( $serialization );
3725
}
3826

3927
private static function assertValidSerialization( $serialization ) {
@@ -62,25 +50,6 @@ public function getSerialization() {
6250
return $this->serialization;
6351
}
6452

65-
/**
66-
* Returns '' for local IDs and the foreign repository name for foreign IDs. For chained IDs (e.g. foo:bar:Q42) it
67-
* will return only the first part.
68-
*
69-
* @return string
70-
*/
71-
public function getRepositoryName() {
72-
return $this->repositoryName;
73-
}
74-
75-
/**
76-
* Returns the serialization without the first repository prefix.
77-
*
78-
* @return string
79-
*/
80-
public function getLocalPart() {
81-
return $this->localPart;
82-
}
83-
8453
/**
8554
* @param string $id
8655
*
@@ -119,17 +88,4 @@ abstract public function __serialize(): array;
11988

12089
abstract public function __unserialize( array $serialized ): void;
12190

122-
/**
123-
* Returns a pair (repository name, local part of ID) from the given ID serialization.
124-
* Note: this does not perform any validation of the given input. Calling code should take
125-
* care of this!
126-
*
127-
* @param string $serialization
128-
*
129-
* @return string[] Array of form [ string $repositoryName, string $localPart ]
130-
*/
131-
protected static function extractRepositoryNameAndLocalPart( $serialization ) {
132-
return array_pad( explode( ':', $serialization, 2 ), -2, '' );
133-
}
134-
13591
}

tests/fixtures/CustomEntityId.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ public function serialize() {
2727

2828
public function __unserialize( array $data ): void {
2929
$this->serialization = $data['serialization'];
30-
$this->repositoryName = '';
31-
$this->localPart = $data['serialization'];
3230
}
3331

3432
/**
@@ -38,8 +36,6 @@ public function __unserialize( array $data ): void {
3836
*/
3937
public function unserialize( $serialized ) {
4038
$this->serialization = $serialized;
41-
$this->repositoryName = '';
42-
$this->localPart = $serialized;
4339
}
4440

4541
/**

tests/unit/Entity/EntityIdTest.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,6 @@ public function testReturnTypeOfToString( EntityId $id ) {
101101
$this->assertIsString( $id->__toString() );
102102
}
103103

104-
/**
105-
* @dataProvider instanceProvider
106-
*/
107-
public function testGetRepositoryName( EntityId $id, $repoName ) {
108-
$this->assertSame( $repoName, $id->getRepositoryName() );
109-
}
110-
111-
public function testGetLocalPart() {
112-
$id = new ItemId( 'Q42' );
113-
$this->assertSame( 'Q42', $id->getLocalPart() );
114-
}
115-
116104
public static function invalidSerializationProvider() {
117105
return [
118106
[ 'foo:Q42' ],

0 commit comments

Comments
 (0)