Skip to content

Commit

Permalink
[Greeter] 朝ならの条件をメソッドに抽出した
Browse files Browse the repository at this point in the history
  • Loading branch information
hidenorigoto committed Oct 9, 2013
1 parent db52475 commit 7c3bcba
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/CodeIQ/Greeter/Greeter.php
Expand Up @@ -26,10 +26,19 @@ function __construct(Clock $clock)
public function greet()
{
$currentTime = $this->clock->getCurrentTime();
if ($currentTime >= new \DateTimeImmutable('05:00:00') &&
$currentTime < new \DateTimeImmutable('12:00:00')
if ($this->timeIsMorning($currentTime)
) {
return 'おはようございます';
}
}

/**
* @param $currentTime
* @return bool
*/
private function timeIsMorning($currentTime)
{
return $currentTime >= new \DateTimeImmutable('05:00:00') &&
$currentTime < new \DateTimeImmutable('12:00:00');
}
}

0 comments on commit 7c3bcba

Please sign in to comment.