supports() public method

Returns true if combination of type and value is supported.
public supports ( string $type, mixed $value ) : boolean
$type string
$value mixed
return boolean
Exemplo n.º 1
0
 /**
  * Load cache lifetime metadata.
  *
  * @param $path
  * @param \DOMXPath $xpath
  *
  * @return array
  */
 private function loadCacheLifetime($path, \DOMXPath $xpath)
 {
     $nodeList = $xpath->query($path);
     if (!$nodeList->length) {
         return ['type' => CacheLifetimeResolverInterface::TYPE_SECONDS, 'value' => 0];
     }
     // get first node
     $node = $nodeList->item(0);
     $type = $node->getAttribute('type');
     if ('' === $type) {
         $type = CacheLifetimeResolverInterface::TYPE_SECONDS;
     }
     $value = $node->nodeValue;
     if (!$this->cacheLifetimeResolver->supports($type, $value)) {
         throw new \InvalidArgumentException(sprintf('CacheLifetime "%s" with type "%s" not supported.', $value, $type));
     }
     return ['type' => $type, 'value' => $value];
 }