diff --git a/.gitignore b/.gitignore index 624a9d7..2a840ee 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /vendor/ /.phpunit.cache/ -.php-cs-fixer.cache +/.phpunit.result.cache +/phpunit.xml +.php-cs-fixer.cache \ No newline at end of file diff --git a/src/Domain/Card.php b/src/Domain/Card.php new file mode 100644 index 0000000..c39ab73 --- /dev/null +++ b/src/Domain/Card.php @@ -0,0 +1,41 @@ +rank) { + 'Jack', 'Queen', 'King' => 10, + 'Ace' => 11, + default => (int) $this->rank, + }; + } + + public function rank(): string + { + return $this->rank; + } + + public function suit(): string + { + return $this->suit; + } +} diff --git a/tests/Domain/CardTest.php b/tests/Domain/CardTest.php new file mode 100644 index 0000000..a12634d --- /dev/null +++ b/tests/Domain/CardTest.php @@ -0,0 +1,37 @@ +assertSame(7, $card->numericValue()); + } + + public function testFaceCardHasNumericValueOf10(): void + { + $card = new Card('Jack', 'Hearts'); + + $this->assertSame(10, $card->numericValue()); + } + + public function testAceHasNumericValueOf11(): void + { + $card = new Card('Ace', 'Spades'); + + $this->assertSame(11, $card->numericValue()); + } + + public function testInvalidRankThrowsException(): void + { + $this->expectException(\InvalidArgumentException::class); + + new Card('invalid', 'Hearts'); + } +} \ No newline at end of file