src/Acl/Collection/PermissionCollection.php
protected function cast($element) {
        if ($element instanceof Permission) {
            return $element;
        }

        if (!is_array($element)) {
            throw new InvalidArgumentException('Element is not an array.');
        }

        foreach (['attributes', 'type', 'value', 'title'] as $key) {
            if (!array_key_exists($key, $element)) {
                throw new InvalidArgumentException('Element is missing key "'.$key.'".');
            }
        }

        $permission = new Permission($element['key'], $element['attributes'], $element['type'], $element['value'], $element['title']);

        return $permission;
    }
protected function cast($element) {
        if ($element instanceof Permission) {
            return $element;
        }

        if (!is_array($element)) {
            throw new InvalidArgumentException('Element is not an array.');
        }

        foreach (['attributes', 'type', 'value', 'title'] as $key) {
            if (!array_key_exists($key, $element)) {
                throw new InvalidArgumentException('Element is missing key "'.$key.'".');
            }
        }

        $permission = new Permission($element['key'], $element['attributes'], $element['type'], $element['value'], $element['title']);

        return $permission;
    }
protected function cast ( $ element ) { if ( $ element instanceof Permission ) { return $ element ; } if ( ! is_array ( $ element ) ) { throw new InvalidArgumentException ( 'Element is not an array.' ) ; } foreach ( [ 'attributes' , 'type' , 'value' , 'title' ] as $ key ) { if ( ! array_key_exists ( $ key , $ element ) ) { throw new InvalidArgumentException ( 'Element is missing key "' . $ key . '".' ) ; } } $ permission = new Permission ( $ element [ 'key' ] , $ element [ 'attributes' ] , $ element [ 'type' ] , $ element [ 'value' ] , $ element [ 'title' ] ) ; return $ permission ; }
Cast element to permission object

@param mixed $element
@return \Ds\Component\Acl\Model\Permission
@throws \InvalidArgumentException
Cast element to permission object