| Conditions | 3 |
| Paths | 3 |
| Total Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 64 | 3 | public function age() |
|
| 65 | { |
||
| 66 | 3 | if ($this->wrappedObject->birthdate == null) { |
|
| 67 | 1 | return; |
|
| 68 | } |
||
| 69 | |||
| 70 | 2 | $reference = new \DateTime(); |
|
| 71 | 2 | $born = new \DateTime($this->wrappedObject->birthdate); |
|
| 72 | |||
| 73 | 2 | if ($this->wrappedObject->birthdate > $reference) { |
|
| 74 | 1 | throw new InvalidContactAgeException; |
|
| 75 | } |
||
| 76 | |||
| 77 | 1 | $diff = $reference->diff($born); |
|
| 78 | |||
| 79 | 1 | return $diff->y; |
|
| 80 | } |
||
| 81 | } |
||
| 82 |