protected function createSplFileInfoObject($entity)
    {
        // This is already a valid object
        if ($entity instanceof \SplFileInfo) {
            return $entity;
        }

        // This is a valid path
        if (is_string($entity) && file_exists($entity)) {
            return new \SplFileInfo($entity);
        }

        // This is an array with a valid object
        $isArray = is_array($entity);
        if ($isArray && $entity[0] instanceof \SplFileInfo) {
            return $entity;
        }

        // This is an array with a valid path
        if ($isArray && is_string($entity[0]) && file_exists($entity[0])) {
            return [new \SplFileInfo($entity[0]), $entity[1]];
        }

        // We've run out of options
        throw new BadFileInfoObjectException('The input array does not hold proper SplFileInfo objects.');
    }
protected function createSplFileInfoObject($entity)
    {
        // This is already a valid object
        if ($entity instanceof \SplFileInfo) {
            return $entity;
        }

        // This is a valid path
        if (is_string($entity) && file_exists($entity)) {
            return new \SplFileInfo($entity);
        }

        // This is an array with a valid object
        $isArray = is_array($entity);
        if ($isArray && $entity[0] instanceof \SplFileInfo) {
            return $entity;
        }

        // This is an array with a valid path
        if ($isArray && is_string($entity[0]) && file_exists($entity[0])) {
            return [new \SplFileInfo($entity[0]), $entity[1]];
        }

        // We've run out of options
        throw new BadFileInfoObjectException('The input array does not hold proper SplFileInfo objects.');
    }
protected function createSplFileInfoObject ( $ entity ) { // This is already a valid object if ( $ entity instanceof \ SplFileInfo ) { return $ entity ; } // This is a valid path if ( is_string ( $ entity ) && file_exists ( $ entity ) ) { return new \ SplFileInfo ( $ entity ) ; } // This is an array with a valid object $ isArray = is_array ( $ entity ) ; if ( $ isArray && $ entity [ 0 ] instanceof \ SplFileInfo ) { return $ entity ; } // This is an array with a valid path if ( $ isArray && is_string ( $ entity [ 0 ] ) && file_exists ( $ entity [ 0 ] ) ) { return [ new \ SplFileInfo ( $ entity [ 0 ] ) , $ entity [ 1 ] ] ; } // We've run out of options throw new BadFileInfoObjectException ( 'The input array does not hold proper SplFileInfo objects.' ) ; }
Check for an \SplFileInfo object or a custom namespaces object
@param $entity
@return \SplFileInfo|\SplFileInfo[]|string
Check for an \ SplFileInfo object or a custom namespaces object