| Total Complexity | 5 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 4 | abstract class AdminModelFactory |
||
| 5 | { |
||
| 6 | protected Config $config; |
||
| 7 | |||
| 8 | public function __construct(Config $config) { |
||
| 9 | $this->config = $config; |
||
| 10 | } |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Create a content object (stdClass) specifically for the admin console. |
||
| 14 | * @param array<int, string> $params When populating with variable arguments, use the following |
||
| 15 | * <b>named parameters<b>: |
||
| 16 | * <ul> |
||
| 17 | * <li>title:</li> |
||
| 18 | * </ul> |
||
| 19 | * @return \stdClass |
||
| 20 | */ |
||
| 21 | public function createAdminContentObject(array $params): \stdClass { |
||
| 22 | $contentObject = new \stdClass(); |
||
| 23 | $contentObject->site = $this->getSiteObject(); |
||
| 24 | if (empty($params['title'])) { |
||
| 25 | throw new \InvalidArgumentException("The 'title:' parameter has not been set!"); |
||
| 26 | } |
||
| 27 | $contentObject->title = $params['title']; |
||
| 28 | return $contentObject; |
||
| 29 | } |
||
| 30 | |||
| 31 | protected function getSiteObject(): \stdClass { |
||
| 46 | } |
||
| 47 | |||
| 48 | } |
||
| 49 |