-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yukihiro Arisawa
committed
Apr 29, 2024
1 parent
79b720e
commit f91b27b
Showing
9 changed files
with
135 additions
and
7 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Iamyukihiro\Aquarium\Domain\Logic; | ||
|
||
class NicknameGenerator | ||
{ | ||
private array $fishNicknames = [ | ||
'ジョン', | ||
'たけし', | ||
'マイク', | ||
'マイケル', | ||
'ジョニー', | ||
'ボブ', | ||
'ありさわ', | ||
'ゆきひろ', | ||
]; | ||
|
||
public function generate(): string | ||
{ | ||
$randomIndex = array_rand($this->fishNicknames); | ||
|
||
return $this->fishNicknames[$randomIndex]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Iamyukihiro\Aquarium\Domain\Logic; | ||
|
||
use Iamyukihiro\Aquarium\Domain\Model\Fish\Medaka; | ||
use Iamyukihiro\Aquarium\Domain\VO\Variety; | ||
|
||
/** | ||
* The psychopathic class. | ||
*/ | ||
class RandomMedakaGenerator | ||
{ | ||
public function __construct( | ||
private NicknameGenerator $nicknameGenerator | ||
) { | ||
} | ||
|
||
public function generate(): Medaka | ||
{ | ||
return new Medaka( | ||
$this->nicknameGenerator->generate() . 'メダカ', | ||
new Variety('みゆき'), | ||
'Swim' | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
/** @noinspection NonAsciiCharacters */ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Iamyukihiro\Aquarium\Domain\Logic; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
class NicknameGeneratorTest extends TestCase | ||
{ | ||
public function test_ニックネームが生成されること(): void | ||
{ | ||
$SUT = $this->getSUT(); | ||
$actual = $SUT->generate(); | ||
|
||
$this->assertIsString($actual); | ||
} | ||
|
||
public function getSUT(): NicknameGenerator | ||
{ | ||
return new NicknameGenerator(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/** @noinspection NonAsciiCharacters */ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Iamyukihiro\Aquarium\Domain\Logic; | ||
|
||
use Iamyukihiro\Aquarium\Domain\Model\Fish\Medaka; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class RandomMedakaGeneratorTest extends TestCase | ||
{ | ||
public function test_メダカが生成されること(): void | ||
{ | ||
$SUT = $this->getSUT(); | ||
$actual = $SUT->generate(); | ||
|
||
$this->assertInstanceOf(Medaka::class, $actual); | ||
$this->assertIsString($actual->getNickName()); | ||
} | ||
|
||
public function getSUT(): RandomMedakaGenerator | ||
{ | ||
return new RandomMedakaGenerator( | ||
new NicknameGenerator() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters