Skip to content

Commit

Permalink
Add 'final' wherever it makes sense.
Browse files Browse the repository at this point in the history
  • Loading branch information
gnutix committed Mar 24, 2014
1 parent e1b6123 commit 33dc5c1
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/GameDomain/Game/AbstractGame.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ abstract class AbstractGame
/**
* {@inheritDoc}
*/
public function __construct(AbstractRulesSet $gameRules)
final public function __construct(AbstractRulesSet $gameRules)
{
$this->gameRules = $gameRules;
}
Expand Down
2 changes: 1 addition & 1 deletion src/GameDomain/Player/Players/PerfectPlayer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class PerfectPlayer implements PlayerInterface
/**
* {@inheritDoc}
*/
public function play(AbstractRulesSet $gameRules, Step $step)
final public function play(AbstractRulesSet $gameRules, Step $step)
{
return $gameRules->generateValidAnswer($step->getRawValue());
}
Expand Down
2 changes: 1 addition & 1 deletion src/GameDomain/Round/AbstractRound.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ abstract class AbstractRound
/**
* @param \LimitIterator $players
*/
public function __construct(\LimitIterator $players)
final public function __construct(\LimitIterator $players)
{
$this->players = $players;
}
Expand Down
2 changes: 1 addition & 1 deletion src/GameDomain/Rule/AbstractRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ abstract class AbstractRule
*
* @return bool
*/
public function isSatisfiedBy(Answer $playerAnswer, $number)
final public function isSatisfiedBy(Answer $playerAnswer, $number)
{
try {
return $playerAnswer->isSameAs($this->generateValidAnswer($number));
Expand Down
14 changes: 7 additions & 7 deletions src/GameDomain/Rule/AbstractRulesSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,18 @@ abstract class AbstractRulesSet extends ArrayCollection
/**
* Constructor
*/
public function __construct()
final public function __construct()
{
$this->loadRules();
}

/**
* Loads the rules
*/
abstract protected function loadRules();

/**
* @param int $number
*
* @return \GameDomain\Round\Step\Answer
* @throws \DomainException
*/
public function generateValidAnswer($number)
final public function generateValidAnswer($number)
{
foreach ($this->toArray() as $gameRule) {
try {
Expand All @@ -43,4 +38,9 @@ public function generateValidAnswer($number)

throw new \DomainException('No valid answer can be generated from the current rules set.');
}

/**
* Loads the rules
*/
abstract protected function loadRules();
}
2 changes: 1 addition & 1 deletion src/Utils/Collections/InfiniteArrayCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class InfiniteArrayCollection extends ArrayCollection
/**
* @return \GameDomain\Player\PlayerInterface[]|\InfiniteIterator
*/
public function getInfiniteIterator()
final public function getInfiniteIterator()
{
$this->first();

Expand Down
10 changes: 5 additions & 5 deletions src/Utils/Domain/AbstractScalarValueObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final public function __construct($value)
/**
* {@inheritDoc}
*/
public function isSameAs($value)
final public function isSameAs($value)
{
// If the given object is not an AbstractScalarValueObject, we can't compare them
if (!$this->areObjectsOfSameType($this, $value)) {
Expand All @@ -36,15 +36,15 @@ public function isSameAs($value)
/**
* {@inheritDoc}
*/
public function getRawValue()
final public function getRawValue()
{
return $this->value;
}

/**
* {@inheritDoc}
*/
public function __toString()
final public function __toString()
{
return (string) $this->getRawValue();
}
Expand All @@ -55,7 +55,7 @@ public function __toString()
* @return bool
* @throws \InvalidArgumentException
*/
protected function guardAgainstNonScalar($value)
final protected function guardAgainstNonScalar($value)
{
if (!is_scalar($value)) {
throw new \InvalidArgumentException(
Expand All @@ -70,7 +70,7 @@ protected function guardAgainstNonScalar($value)
*
* @return bool
*/
protected function areObjectsOfSameType($value1, $value2)
final protected function areObjectsOfSameType($value1, $value2)
{
return is_object($value1) && is_object($value2) && (get_class($value1) === get_class($value2));
}
Expand Down

0 comments on commit 33dc5c1

Please sign in to comment.