| 1 | <?php |
||
| 8 | class Country implements ValueObjectInterface |
||
| 9 | { |
||
| 10 | /** @var CountryCode */ |
||
| 11 | protected $code; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * Returns a new Country object given a native PHP string country code |
||
| 15 | * |
||
| 16 | * @param string $code |
||
|
|
|||
| 17 | * @return self |
||
| 18 | */ |
||
| 19 | 2 | public static function fromNative() |
|
| 20 | { |
||
| 21 | 2 | $codeString = \func_get_arg(0); |
|
| 22 | 2 | $code = CountryCode::getByName($codeString); |
|
| 23 | 2 | $country = new self($code); |
|
| 24 | |||
| 25 | 2 | return $country; |
|
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Returns a new Country object |
||
| 30 | * |
||
| 31 | * @param CountryCode $code |
||
| 32 | */ |
||
| 33 | 16 | public function __construct(CountryCode $code) |
|
| 37 | |||
| 38 | /** |
||
| 39 | * Tells whether two Country are equal |
||
| 40 | * |
||
| 41 | * @param ValueObjectInterface $country |
||
| 42 | * @return bool |
||
| 43 | */ |
||
| 44 | 5 | public function sameValueAs(ValueObjectInterface $country) |
|
| 45 | { |
||
| 46 | 5 | if (false === Util::classEquals($this, $country)) { |
|
| 47 | 1 | return false; |
|
| 48 | } |
||
| 49 | |||
| 50 | 5 | return $this->getCode()->sameValueAs($country->getCode()); |
|
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Returns country code |
||
| 55 | * |
||
| 56 | * @return CountryCode |
||
| 57 | */ |
||
| 58 | 9 | public function getCode() |
|
| 62 | |||
| 63 | /** |
||
| 64 | * Returns country name |
||
| 65 | * |
||
| 66 | * @return String |
||
| 67 | */ |
||
| 68 | 3 | public function getName() |
|
| 69 | { |
||
| 70 | 3 | $code = $this->getCode(); |
|
| 71 | 3 | $name = CountryCodeName::getName($code); |
|
| 72 | |||
| 73 | 3 | return $name; |
|
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Returns country name as native string |
||
| 78 | * |
||
| 79 | * @return string |
||
| 80 | */ |
||
| 81 | 2 | public function __toString() |
|
| 85 | |||
| 86 | function jsonSerialize() |
||
| 87 | { |
||
| 88 | return (string) $this; |
||
| 90 | |||
| 91 | |||
| 92 | } |
||
| 93 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.