Factory/RootFactory.php
public function createEntity(array $data, $root = false)
    {
        if (false === $root) {
            $root = Root::create();
        }

        if (isset($data['token'])) {
            $root = $root->setToken((new TokenFactory())->createEntity($data['token']));
        }

        if (isset($data['_links'])) {
            $root = $root->setLinks($data['_links']);
        }

        return $root;
    }
public function createEntity(array $data, $root = false)
    {
        if (false === $root) {
            $root = Root::create();
        }

        if (isset($data['token'])) {
            $root = $root->setToken((new TokenFactory())->createEntity($data['token']));
        }

        if (isset($data['_links'])) {
            $root = $root->setLinks($data['_links']);
        }

        return $root;
    }
@param array $data
@param false|Root $root

@return Root