{$name}; } throw new \TypeError("undefined property {$name}"); } /** * Make and instance * * @param integer $type The node menu type. * @param boolean $published The node menu published. * @param string $title The node menu title. * @param array $link The node menu link. * @return \App\Lib\Definitions\MenuNode * @throws \RuntimeException If $type or $data is wrong. */ public static function make(int $type, bool $published, string $title, array $link): self { self::assertTypeIsCorrect($type); $menuNode = new self(); // @phpstan-ignore-next-line $menuNode->type = MenuNodeType::make($type); // @phpstan-ignore-next-line $menuNode->published = $published; // @phpstan-ignore-next-line $menuNode->title = $title; // @phpstan-ignore-next-line $menuNode->link = new Link(...$link); return $menuNode; } /** * Assert Type is correct * * @param integer $type * @return void * @throws \RuntimeException If $type is wrong. */ public static function assertTypeIsCorrect(int $type) { try { $type = MenuNodeType::make($type); } catch (\BadMethodCallException $e) { throw new \RuntimeException($e->getMessage()); } } }