hendrikmaus/reynaldo

View on GitHub
src/Elements/ResourceElement.php

Summary

Maintainability
A
0 mins
Test Coverage
A
90%
<?php

namespace Hmaus\Reynaldo\Elements;

class ResourceElement extends BaseElement implements ApiElement, ApiResource
{
    public function getHref()
    {
        return $this->getAttribute('href');
    }

    public function getTransitions()
    {
        return $this->getElementsByType(HttpTransitionElement::class);
    }

    public function getHrefVariablesElement()
    {
        $element = $this->getAttribute('hrefVariables');

        if (!$element) {
            $element = new HrefVariablesElement([]);
        }

        return $element;
    }

    public function getDataStructure()
    {
        return $this->getFirstElementByType(DataStructureElement::class);
    }
}