Skip to content

Instantly share code, notes, and snippets.

@CamKem
Created March 25, 2023 10:40
Show Gist options
  • Save CamKem/adc68f85ef3baeeb52b04527f05cb113 to your computer and use it in GitHub Desktop.
Save CamKem/adc68f85ef3baeeb52b04527f05cb113 to your computer and use it in GitHub Desktop.
Player Class for Tennis Match Kata
<?php
namespace Tests\Feature\Katas;
class Player
{
public int $points = 0;
public string $name;
public function __construct(string $name)
{
$this->name = $name;
}
public function scorePoint(): void
{
$this->points++;
}
public function toScore(): string
{
switch($this->points) {
case 0:
return 'love';
case 1:
return 'fifteen';
case 2:
return 'thirty';
case 3:
return 'forty';
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment