for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file contains functionality relating to the fun match teams
*
* @package BZiON\Models
* @license https://github.com/allejo/bzion/blob/master/LICENSE.md GNU General Public License Version 3
*/
* A team identified by its color in BZFlag
class ColorTeam implements TeamInterface
{
* The color of the team
* @var string
protected $color;
* Define a new ColorTeam
* @param string $color The color of the team
public function __construct($color)
$this->color = strtolower($color);
}
* Get a unique identifier for the team
* @return string
public function getId()
return $this->color;
* {@inheritdoc}
public function getName()
return ucwords($this->color) . " Team";
public function getAvatar()
return "assets/imgs/team_" . $this->color . ".png";
public function isValid()
return true;
public function isLastMatch($match)
public function supportsMatchCount()
return false;
* Return whether a team color is valid
* @param string $color The color to check
public static function isValidTeamColor($color)
return in_array($color, array('red', 'green', 'blue', 'purple'));
public function isSameAs($team)
$sameType = $this instanceof $team || $team instanceof $this;
return $sameType && $this->color === $team->color;
color
TeamInterface
instanceof
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Adding an additional type check:
interface SomeInterface { } class SomeClass implements SomeInterface { public $a; } function someFunction(SomeInterface $object) { if ($object instanceof SomeClass) { $a = $object->a; } }
Changing the type hint:
interface SomeInterface { } class SomeClass implements SomeInterface { public $a; } function someFunction(SomeClass $object) { $a = $object->a; }
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: