From ccbf9d9a93f7debadb0d38f4269bdeef1b12fb7b Mon Sep 17 00:00:00 2001 From: Sam Lee Date: Mon, 24 Feb 2025 16:05:09 +0900 Subject: [PATCH] Rename `Location` to `LocationCode` class --- README.md | 6 ++-- src/{Location.php => LocationCode.php} | 10 +++---- ...{LocationTest.php => LocationCodeTest.php} | 30 +++++++++---------- 3 files changed, 23 insertions(+), 23 deletions(-) rename src/{Location.php => LocationCode.php} (90%) rename tests/{LocationTest.php => LocationCodeTest.php} (70%) diff --git a/README.md b/README.md index d592287..ce2dddf 100644 --- a/README.md +++ b/README.md @@ -206,9 +206,9 @@ print ReceiptCode::of(prefix: 'CT')->nextCode(); ### Location Code ```php -print Location::of(warehouse: 'AUK', rack: 'R3', shelf: 'S32')->locationCode(); -print Location::of(['warehouse' => 'AUK', 'rack' => 'R3', 'shelf' => 'S32')->locationCode(); -print Location::of(warehouse: 'AUK', rack: 'R3', shelf: 'S32'); //` Stringable` supported +print LocationCode::of(warehouse: 'AUK', rack: 'R3', shelf: 'S32')->locationCode(); +print LocationCode::of(['warehouse' => 'AUK', 'rack' => 'R3', 'shelf' => 'S32')->locationCode(); +print LocationCode::of(warehouse: 'AUK', rack: 'R3', shelf: 'S32'); //` Stringable` supported //=> AUK-R3-S32 ``` diff --git a/src/Location.php b/src/LocationCode.php similarity index 90% rename from src/Location.php rename to src/LocationCode.php index 0547626..7a02200 100644 --- a/src/Location.php +++ b/src/LocationCode.php @@ -11,7 +11,7 @@ * * @since 2025-02-24 */ -class Location implements Stringable +class LocationCode implements Stringable { /** * Code representing the product’s storage location @@ -65,7 +65,7 @@ private function __construct( * * @return string The method returns the location code * - * @example print Location::of(warehouse: 'AUK', rack: 'R3', shelf: 'S32')->locationCode(); + * @example print LocationCode::of(warehouse: 'AUK', rack: 'R3', shelf: 'S32')->locationCode(); */ public function locationCode(): string { @@ -113,12 +113,12 @@ public static function of( } /** - * Get the string representation of the location. + * Get the string representation of the location code. * * @return string The magic method returns the location code * - * @example print Location::of(warehouse: 'A1') => 'A1' - * @example print Location::of(warehouse: 'A1', rack: 'B3') => 'A1-B3' + * @example print LocationCode::of(warehouse: 'A1') => 'A1' + * @example print LocationCode::of(warehouse: 'A1', rack: 'B3') => 'A1-B3' */ public function __toString(): string { diff --git a/tests/LocationTest.php b/tests/LocationCodeTest.php similarity index 70% rename from tests/LocationTest.php rename to tests/LocationCodeTest.php index 7208286..d8baaef 100644 --- a/tests/LocationTest.php +++ b/tests/LocationCodeTest.php @@ -2,20 +2,20 @@ namespace Cable8mm\GoodCode\Tests; -use Cable8mm\GoodCode\Location; +use Cable8mm\GoodCode\LocationCode; use PHPUnit\Framework\TestCase; -class LocationTest extends TestCase +class LocationCodeTest extends TestCase { public function test_full_location_code() { - $this->assertEquals('AUK-R3-S32', Location::of( + $this->assertEquals('AUK-R3-S32', LocationCode::of( warehouse: 'AUK', rack: 'R3', shelf: 'S32' )->locationCode()); - $this->assertEquals('AUK-R3-S32', Location::of([ + $this->assertEquals('AUK-R3-S32', LocationCode::of([ 'warehouse' => 'AUK', 'rack' => 'R3', 'shelf' => 'S32', @@ -24,12 +24,12 @@ public function test_full_location_code() public function test_location_code_without_warehouse() { - $this->assertEquals('R3-S32', Location::of( + $this->assertEquals('R3-S32', LocationCode::of( rack: 'R3', shelf: 'S32' )->locationCode()); - $this->assertEquals('R3-S32', Location::of([ + $this->assertEquals('R3-S32', LocationCode::of([ 'rack' => 'R3', 'shelf' => 'S32', ])->locationCode()); @@ -37,12 +37,12 @@ public function test_location_code_without_warehouse() public function test_location_code_without_shelf() { - $this->assertEquals('AUK-R3', Location::of( + $this->assertEquals('AUK-R3', LocationCode::of( warehouse: 'AUK', rack: 'R3' )->locationCode()); - $this->assertEquals('AUK-R3', Location::of([ + $this->assertEquals('AUK-R3', LocationCode::of([ 'warehouse' => 'AUK', 'rack' => 'R3', ])->locationCode()); @@ -50,11 +50,11 @@ public function test_location_code_without_shelf() public function test_location_code_with_only_warehouse() { - $this->assertEquals('AUK', Location::of( + $this->assertEquals('AUK', LocationCode::of( warehouse: 'AUK' )->locationCode()); - $this->assertEquals('AUK', Location::of([ + $this->assertEquals('AUK', LocationCode::of([ 'warehouse' => 'AUK', ])->locationCode()); } @@ -63,7 +63,7 @@ public function test_location_code_with_only_rack_excepted() { $this->expectException(\InvalidArgumentException::class); - Location::of([ + LocationCode::of([ 'rack2' => 'R3', ]); } @@ -72,7 +72,7 @@ public function test_location_code_with_only_shelf_excepted() { $this->expectException(\InvalidArgumentException::class); - Location::of([ + LocationCode::of([ 'shelf2' => 'S32', ]); } @@ -81,18 +81,18 @@ public function test_location_code_with_empty() { $this->expectException(\InvalidArgumentException::class); - Location::of(); + LocationCode::of(); } public function test_location_code_to_string() { - $this->assertEquals('AUK-R3-S32', (string) Location::of( + $this->assertEquals('AUK-R3-S32', (string) LocationCode::of( warehouse: 'AUK', rack: 'R3', shelf: 'S32' )); - $this->assertEquals('AUK-R3-S32', (string) Location::of([ + $this->assertEquals('AUK-R3-S32', (string) LocationCode::of([ 'warehouse' => 'AUK', 'rack' => 'R3', 'shelf' => 'S32',