@param \Yosmanyga\Resource\Resource $resource

@throws \RuntimeException If no reader is able to support the
resource

@return \Yosmanyga\Resource\Reader\Iterator\ReaderInterface
504865
protected function pickReader($resource)
    {
        foreach ($this->readers as $i => $reader) {
            if ($reader->supports($resource)) {
                if (0 != $i) {
                    // Move reader to top to improve next pick
                    unset($this->readers[$i]);
                    array_unshift($this->readers, $reader);
                }

                return $reader;
            }
        }

        throw new \RuntimeException('No reader is able to support the resource.');
    }
61460
public function resolve($resource): Stream
    {
        // detect best way to load and process configuration content
        if (is_array($resource)) {
            return new DataStream($resource, new ArrayProcessor());
        } elseif (is_callable($resource)) {
            return new DataStream($resource, new CallableProcessor());
        } elseif ($resource instanceof Config) {
            return new DataStream($resource, new ConfigProcessor());
        } elseif ($resource instanceof Collection) {
            return new DataStream($resource, new CollectionProcessor());
        } elseif ($resource instanceof Stream) {
            return $resource;
        } elseif ($resource instanceof stdClass) {
            return new DataStream($resource, new StdClassProcessor());
        } elseif (is_string($resource)) {
            $filesHandlers = $this->filesHandlers;
            if (null === $filesHandlers) {
                $filesHandlers = new FilesHandlers(null);
            }
            return new FileStream($resource, $filesHandlers);
        }

        throw new UnknownResourceException($resource);
    }
229779
static public function createFromResource($resource) {
		if (!is_resource($resource))
			throw new Exception('Invalid (resource) parameter! This is not a resource!');
		if (get_resource_type($resource) != 'gd')
			throw new Exception('Invalid (resource) parameter! Resource is not a gd resource!');
		return new self($resource);
	}
856497
protected function parseComposerContent($resource)
    {
        $composer = (array) JsonFile::parseJson($this->getContents($resource));
        if (empty($composer['content']) || 'base64' !== $composer['encoding'] || !($composer = base64_decode($composer['content'], true))) {
            throw new \RuntimeException('Could not retrieve '.$this->repoConfig['filename'].' from '.$resource);
        }

        return $composer;
    }
633345
public function getForResource($resource)
    {
        $resourceName = $this->resourceName($resource);

        if (isset($this->resourceFactories[$resourceName])) {
            return $this->resourceFactories[$resourceName];
        }

        throw new HandlerNotFoundException("No handler found for resource '$resourceName'");

    }
1231821
public function optionsAction( $resource )
	{
		$response = $this->createAdmin( $resource )->options( $this->getPsrRequest(), new Response() );
		return $this->setPsrResponse( $response );
	}
960123
public function by($resource)
    {
        $resourceName = $resource instanceof AppliesToResource ? $resource->resourceName() : $resource;

        return new static($this->model, $resourceName);
    }
31314
public static function toArray($resource) {
		if (self::isArray($resource)) {
			return $resource;

		} else if (self::isObject($resource)) {
			return self::buildArray($resource);

		} else if (self::isJson($resource)) {
			return json_decode($resource, true);

		} else if ($ser = self::isSerialized($resource)) {
			return self::toArray($ser);

		} else if ($xml = self::isXml($resource)) {
			return self::xmlToArray($xml);
		}

		return $resource;
	}
22465
public static function create($resource)
    {
        $type = gettype($resource);

        if ($type == 'string') {
            $stream = fopen('php://temp', 'r+');

            if ($resource !== '') {
                fwrite($stream, $resource);
                fseek($stream, 0);
            }

            return new self($stream);
        }

        if ($type == 'resource') {
            return new self($resource);
        }

        if ($resource instanceof StreamableInterface) {
            return $resource;
        }

        throw new \InvalidArgumentException('Invalid resource type: ' . $type);
    }
377680
public function set(ResourceInterface $resource): ResourceCollectionInterface
    {
        $this->collection[$this->buildArrayKey($resource->type(), $resource->id())] = $resource;

        return $this;
    }
588335
public function load($resource)
    {
        if ($this->cacher->check($resource)) {
            return $this->cacher->retrieve($resource);
        }

        $this->reader->open($resource);

        /** @var \Yosmanyga\Validation\Resource\Definition\ObjectDefinition[] $definitions */
        $definitions = [];
        /** @var \Yosmanyga\Validation\Validator\ObjectValidator[] $validators */
        $validators = [];
        while ($data = $this->reader->current()) {
            /** @var \Yosmanyga\Validation\Resource\Definition\ObjectDefinition $definition */
            $definition = $this->normalizer->normalize($data, $resource);

            $definitions[$definition->class] = $definition;
            $validators[$definition->class] = $this->compiler->compile($definition);

            $this->reader->next();
        }

        $validators = $this->fillObjectValidators($definitions, $validators);

        $this->cacher->store($validators, $resource);

        return $validators;
    }
410795
public function setResource(ResourceInterface $resource = null)
    {
        $this->resource = $resource;

        // Clear urls
        $this->urls = null;

        return $this;
    }
912376
public function create($resource)
    {
        $className = $this->getResourceClassName($resource->type);
        if (!class_exists($className)) {
            throw new Exception(
                'Unknown resource type "' . $resource->type . '".',
                Exception::UNKNOWN_RESOURCE_TYPE
            );
        }

        /** @var AbstractResource $object */
        $object = $this->objectManager->get($className);

        foreach ($resource as $property => $value) {
            if (!ObjectAccess::isPropertySettable($object, $property)) {
                continue;
            }
            ObjectAccess::setProperty($object, $property, $value);
        }

        $this->postProcessResources($object);

        return $object;
    }
1317660
public function on($resource)
    {
        if (!$this->runnable()) {
            throw new \InvalidArgumentException('Command execution is restricted.');
        }

        if (is_array($resource)) {
            return $this->executeOnMulitpleResources($resource);
        }

        return $this->executeOn($resource);
    }
72703
public function createTrackedObject(ResourceInterface $resource)
    {
        $tracked = new TrackedObject();
        $tracked->setResource($resource);
        $tracked->setChecksum($resource->getChecksum());

        if(is_null($tracked->getID())){
            $tracked->setID(PathUtil::createPathID($resource->getResource()));
        }
        return $tracked;
    }
1086796
public function load($resource, $type = null)
    {
        if ($this->loaded) {
            throw new RuntimeException('Do not add this loader twice');
        }

        $routes = new RouteCollection();

        $routes->add($this->inputControllerRouteName, new Route($this->inputResizeControllerRoute, [
            '_controller' => 'elcodi.controller.metric_input:addEntryAction',
        ]));

        $this->loaded = true;

        return $routes;
    }
385745
private function getTranslationFactory($resource, ContainerBuilder $container)
    {
        $translation = null;

        foreach ($container->getDefinition('lug.resource.'.$resource)->getMethodCalls() as $methodCall) {
            if ($methodCall[0] === 'addRelation' && $methodCall[1][0] === 'translation') {
                $translation = $container->getDefinition((string) $methodCall[1][1])->getArgument(0);
            }
        }

        return new Reference('lug.factory.'.$translation);
    }