| Total Complexity | 4 | 
| Total Lines | 51 | 
| Duplicated Lines | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 1 | 
| 1 | <?php | ||
| 16 | final class TelephoneNumber extends AbstractMdElement | ||
| 17 | { | ||
| 18 | use XMLStringElementTrait; | ||
|  | |||
| 19 | |||
| 20 | |||
| 21 | /** | ||
| 22 | * @param string $content | ||
| 23 | */ | ||
| 24 | public function __construct(string $content) | ||
| 25 |     { | ||
| 26 | $this->setContent($content); | ||
| 27 | } | ||
| 28 | |||
| 29 | |||
| 30 | /** | ||
| 31 | * Validate the content of the element. | ||
| 32 | * | ||
| 33 | * @param string $content The value to go in the XML textContent | ||
| 34 | * @throws \Exception on failure | ||
| 35 | * @return void | ||
| 36 | */ | ||
| 37 | protected function validateContent(string $content): void | ||
| 38 |     { | ||
| 39 | Assert::notEmpty($content, 'TelephoneNumber cannot be empty'); | ||
| 40 | } | ||
| 41 | |||
| 42 | |||
| 43 | /** | ||
| 44 | * Create a class from an array | ||
| 45 | * | ||
| 46 | * @param array $data | ||
| 47 | * @return self | ||
| 48 | */ | ||
| 49 | public static function fromArray(array $data): object | ||
| 50 |     { | ||
| 51 | Assert::notEmpty($data); | ||
| 52 | Assert::count($data, 1); | ||
| 53 | |||
| 54 | $index = array_key_first($data); | ||
| 55 | return new self($data[$index]); | ||
| 56 | } | ||
| 57 | |||
| 58 | |||
| 59 | /** | ||
| 60 | * Create an array from this class | ||
| 61 | * | ||
| 62 | * @return array | ||
| 63 | */ | ||
| 64 | public function toArray(): array | ||
| 67 | } | ||
| 68 | } | ||
| 69 |