File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,15 +51,11 @@ private function assertValidIdFormat( $idSerialization ) {
5151 /**
5252 * @see Int32EntityId::getNumericId
5353 *
54- * @throws RuntimeException if called on a foreign ID.
5554 * @return int Guaranteed to be a distinct integer in the range [1..2147483647].
5655 */
5756 public function getNumericId () {
58- if ( $ this ->isForeign () ) {
59- throw new RuntimeException ( 'getNumericId must not be called on foreign ItemIds ' );
60- }
61-
62- return (int )substr ( $ this ->serialization , 1 );
57+ $ serializationParts = self ::splitSerialization ( $ this ->serialization );
58+ return (int )substr ( $ serializationParts [2 ], 1 );
6359 }
6460
6561 /**
Original file line number Diff line number Diff line change @@ -51,15 +51,11 @@ private function assertValidIdFormat( $idSerialization ) {
5151 /**
5252 * @see Int32EntityId::getNumericId
5353 *
54- * @throws RuntimeException if called on a foreign ID.
5554 * @return int Guaranteed to be a distinct integer in the range [1..2147483647].
5655 */
5756 public function getNumericId () {
58- if ( $ this ->isForeign () ) {
59- throw new RuntimeException ( 'getNumericId must not be called on foreign PropertyIds ' );
60- }
61-
62- return (int )substr ( $ this ->serialization , 1 );
57+ $ serializationParts = self ::splitSerialization ( $ this ->serialization );
58+ return (int )substr ( $ serializationParts [2 ], 1 );
6359 }
6460
6561 /**
Original file line number Diff line number Diff line change @@ -81,6 +81,11 @@ public function testGetNumericId() {
8181 $ this ->assertSame ( 1 , $ id ->getNumericId () );
8282 }
8383
84+ public function testGetNumericId_foreignId () {
85+ $ id = new ItemId ( 'foo:Q1 ' );
86+ $ this ->assertSame ( 1 , $ id ->getNumericId () );
87+ }
88+
8489 public function testGetEntityType () {
8590 $ id = new ItemId ( 'Q1 ' );
8691 $ this ->assertSame ( 'item ' , $ id ->getEntityType () );
@@ -151,9 +156,4 @@ public function invalidNumericIdProvider() {
151156 ];
152157 }
153158
154- public function testGetNumericIdThrowsExceptionOnForeignIds () {
155- $ this ->setExpectedException ( RuntimeException::class );
156- ( new ItemId ( 'foo:Q42 ' ) )->getNumericId ();
157- }
158-
159159}
Original file line number Diff line number Diff line change @@ -81,6 +81,11 @@ public function testGetNumericId() {
8181 $ this ->assertSame ( 1 , $ id ->getNumericId () );
8282 }
8383
84+ public function testGetNumericId_foreignId () {
85+ $ id = new PropertyId ( 'foo:P1 ' );
86+ $ this ->assertSame ( 1 , $ id ->getNumericId () );
87+ }
88+
8489 public function testGetEntityType () {
8590 $ id = new PropertyId ( 'P1 ' );
8691 $ this ->assertSame ( 'property ' , $ id ->getEntityType () );
@@ -151,9 +156,4 @@ public function invalidNumericIdProvider() {
151156 ];
152157 }
153158
154- public function testGetNumericIdThrowsExceptionOnForeignIds () {
155- $ this ->setExpectedException ( RuntimeException::class );
156- ( new PropertyId ( 'foo:P42 ' ) )->getNumericId ();
157- }
158-
159159}
You can’t perform that action at this time.
0 commit comments