public function matchPartialId($id, array $resources, $name = 'Resource')
    {
        $matched = array_filter($resources, function (ApiResource $resource) use ($id) {
            return strpos($resource->getProperty('id'), $id) === 0;
        });

        if (count($matched) > 1) {
            $matchedIds = array_map(function (ApiResource $resource) {
                return $resource->getProperty('id');
            }, $matched);
            throw new \InvalidArgumentException(sprintf(
                'The partial ID "<error>%s</error>" is ambiguous; it matches the following %s IDs: %s',
                $id,
                strtolower($name),
                "\n  " . implode("\n  ", $matchedIds)
            ));
        } elseif (count($matched) === 0) {
            throw new \InvalidArgumentException(sprintf('%s not found: "<error>%s</error>"', $name, $id));
        }

        return reset($matched);
    }
public function matchPartialId($id, array $resources, $name = 'Resource')
    {
        $matched = array_filter($resources, function (ApiResource $resource) use ($id) {
            return strpos($resource->getProperty('id'), $id) === 0;
        });

        if (count($matched) > 1) {
            $matchedIds = array_map(function (ApiResource $resource) {
                return $resource->getProperty('id');
            }, $matched);
            throw new \InvalidArgumentException(sprintf(
                'The partial ID "<error>%s</error>" is ambiguous; it matches the following %s IDs: %s',
                $id,
                strtolower($name),
                "\n  " . implode("\n  ", $matchedIds)
            ));
        } elseif (count($matched) === 0) {
            throw new \InvalidArgumentException(sprintf('%s not found: "<error>%s</error>"', $name, $id));
        }

        return reset($matched);
    }
public function matchPartialId ( $ id , array $ resources , $ name = 'Resource' ) { $ matched = array_filter ( $ resources , function ( ApiResource $ resource ) use ( $ id ) { return strpos ( $ resource -> getProperty ( 'id' ) , $ id ) === 0 ; } ) ; if ( count ( $ matched ) > 1 ) { $ matchedIds = array_map ( function ( ApiResource $ resource ) { return $ resource -> getProperty ( 'id' ) ; } , $ matched ) ; throw new \ InvalidArgumentException ( sprintf ( 'The partial ID "<error>%s</error>" is ambiguous; it matches the following %s IDs: %s' , $ id , strtolower ( $ name ) , "\n  " . implode ( "\n  " , $ matchedIds ) ) ) ; } elseif ( count ( $ matched ) === 0 ) { throw new \ InvalidArgumentException ( sprintf ( '%s not found: "<error>%s</error>"' , $ name , $ id ) ) ; } return reset ( $ matched ) ; }
Get a resource, matching on the beginning of the ID.

@param string        $id
@param ApiResource[] $resources
@param string        $name

@return ApiResource
The resource, if one (and only one) is matched.
Get a resource matching on the beginning of the ID .