| Total Complexity | 6 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | class News extends Message |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * @var string |
||
| 23 | */ |
||
| 24 | protected $type = 'news'; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @var array |
||
| 28 | */ |
||
| 29 | protected $properties = [ |
||
| 30 | 'items', |
||
| 31 | ]; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * News constructor. |
||
| 35 | * |
||
| 36 | * @param array $items |
||
| 37 | */ |
||
| 38 | 3 | public function __construct(array $items = []) |
|
| 41 | 3 | } |
|
| 42 | |||
| 43 | /** |
||
| 44 | * @param array $data |
||
| 45 | * @param array $aliases |
||
| 46 | * |
||
| 47 | * @return array |
||
| 48 | */ |
||
| 49 | 1 | public function propertiesToArray(array $data, array $aliases = []): array |
|
| 50 | { |
||
| 51 | 1 | return ['articles' => array_map(function ($item) { |
|
| 52 | 1 | if ($item instanceof NewsItem) { |
|
| 53 | 1 | return $item->toJsonArray(); |
|
| 54 | } |
||
| 55 | 1 | }, $this->get('items'))]; |
|
|
|
|||
| 56 | } |
||
| 57 | |||
| 58 | 2 | public function toXmlArray() |
|
| 71 | ]; |
||
| 72 | } |
||
| 74 |