src/TemplateHelper.php
public function getImageObject($input, $identifier = null, $context = null)
    {
        if ($input instanceof AbstractLocalImage) {
            if (null !== $identifier) {
                $input->setIdentifier($identifier);
            }
            if (null !== $context) {
                $input->setContext($context);
            }

            return $input;
        }
        if ($input instanceof \SplFileInfo) {
            return new FileInfo($input, $identifier, $context);
        } elseif (\is_string($input)) {
            if (preg_match('/^[0-9a-f]{6,40}$/', $input)) {
                return new RokkaHash($input, $identifier, $context, $this);
            }

            return new FileInfo(new \SplFileInfo($input), $identifier, $context);
        }

        throw new \RuntimeException('getImageObject: Input could not be converted to a LocalImageAbstract object');
    }
public function getImageObject($input, $identifier = null, $context = null)
    {
        if ($input instanceof AbstractLocalImage) {
            if (null !== $identifier) {
                $input->setIdentifier($identifier);
            }
            if (null !== $context) {
                $input->setContext($context);
            }

            return $input;
        }
        if ($input instanceof \SplFileInfo) {
            return new FileInfo($input, $identifier, $context);
        } elseif (\is_string($input)) {
            if (preg_match('/^[0-9a-f]{6,40}$/', $input)) {
                return new RokkaHash($input, $identifier, $context, $this);
            }

            return new FileInfo(new \SplFileInfo($input), $identifier, $context);
        }

        throw new \RuntimeException('getImageObject: Input could not be converted to a LocalImageAbstract object');
    }
public function getImageObject ( $ input , $ identifier = null , $ context = null ) { if ( $ input instanceof AbstractLocalImage ) { if ( null !== $ identifier ) { $ input -> setIdentifier ( $ identifier ) ; } if ( null !== $ context ) { $ input -> setContext ( $ context ) ; } return $ input ; } if ( $ input instanceof \ SplFileInfo ) { return new FileInfo ( $ input , $ identifier , $ context ) ; } elseif ( \ is_string ( $ input ) ) { if ( preg_match ( '/^[0-9a-f]{6,40}$/' , $ input ) ) { return new RokkaHash ( $ input , $ identifier , $ context , $ this ) ; } return new FileInfo ( new \ SplFileInfo ( $ input ) , $ identifier , $ context ) ; } throw new \ RuntimeException ( 'getImageObject: Input could not be converted to a LocalImageAbstract object' ) ; }
Returns a LocalImage object depending on the input.

If input is
- LocalImageAbstract: returns that, sets $identidier and $context, if set
- SplFileInfo: returns \Rokka\Client\LocalImage\FileInfo
- string with hash pattern (/^[0-9a-f]{6,40}$/): returns \Rokka\Client\LocalImage\RokkaHash
- other strings: returns \Rokka\Client\LocalImage\FileInfo with $input as the path to the image

@since 1.3.1

@param AbstractLocalImage|string|\SplFileInfo $input
@param string|null                            $identifier
@param mixed                                  $context

@throws \RuntimeException

@return AbstractLocalImage
Returns a LocalImage object depending on the input .