Skip to content

Commit e6f80da

Browse files
committed
IdProviderFactory.php
- new method naming - instead of isUniqueId use name getUniqueIdChecker to reflect the functionality better
1 parent 4fbc9bb commit e6f80da

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/IdProvider.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ class IdProvider {
2929
* @var callable Function to decide if string ID already exists, i.e. is already used as a
3030
* WikiPage
3131
*/
32-
private $isUniqueId;
32+
private $getUniqueIdChecker;
3333

3434
/**
3535
* @param $generator
36-
* @param null $isUniqueId
36+
* @param null $getUniqueIdChecker
3737
*/
38-
public function __construct( $generator, $isUniqueId = null ) {
38+
public function __construct( $generator, $getUniqueIdChecker = null ) {
3939
$this->generator = $generator;
40-
$this->isUniqueId = $isUniqueId;
40+
$this->getUniqueIdChecker = $getUniqueIdChecker;
4141
}
4242

4343
public function getId( array $params = [] ): string {
@@ -47,7 +47,7 @@ public function getId( array $params = [] ): string {
4747
$prefix = trim( $prefix );
4848
$id = $prefix . $this->generator->generate();
4949
if ( !$skipUniqueTest ) {
50-
while ( !( $this->isUniqueId )( $id ) ) {
50+
while ( !( $this->getUniqueIdChecker )( $id ) ) {
5151
$id = $prefix . $this->generator->generate();
5252
}
5353
}

src/IdProviderFactory.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static function random( array $params = [] ) {
3939
}
4040

4141
private static function provider( $generator ) {
42-
return new IdProvider( $generator, self::isUniqueId() );
42+
return new IdProvider( $generator, self::getUniqueIdChecker() );
4343
}
4444

4545
private static function dbExecute() {
@@ -65,7 +65,7 @@ private static function dbExecute() {
6565
* @param string $text The title or ID to check for uniqueness of the wiki page.
6666
* @return \Closure
6767
*/
68-
private static function isUniqueId() {
68+
private static function getUniqueIdChecker() {
6969
return function ( $text ) {
7070
$title = Title::newFromText( $text );
7171

tests/phpunit/Unit/IdProviderFactoryTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ public function testIncrementCreatesIncrementIdGenerator() {
5151
$this->assertEquals( IncrementIdGenerator::class, $provider->generatorClass() );
5252
}
5353

54-
public function testIsUniqueId() {
54+
public function testGetUniqueIdChecker() {
5555
// Call the private method using Reflection
56-
$reflection = new \ReflectionMethod( IdProviderFactory::class, 'isUniqueId' );
56+
$reflection = new \ReflectionMethod( IdProviderFactory::class, 'getUniqueIdChecker' );
5757
$reflection->setAccessible( true );
5858
$isUniqueClosure = $reflection->invoke( null );
5959

0 commit comments

Comments
 (0)