src/fwidm/dwdHourlyCrawler/util/FractalWrapper.php
public static function toResource($obj, $transformer): ResourceAbstract
    {
        if (!$obj)
            return new NullResource();
        $resource = null;
        try {
            if (is_array($obj)) {
                $resource = new Collection($obj, new $transformer(), get_class($obj[0]));
            } else {
                $resource = new Item($obj, new $transformer(), get_class($obj));
            }
        } catch (\Error $e) {
            throw new DWDLibException("Specified transformer is not a class. Got transformer with the class=" . get_class($transformer));
        }
        return $resource;
    }
public static function toResource($obj, $transformer): ResourceAbstract
    {
        if (!$obj)
            return new NullResource();
        $resource = null;
        try {
            if (is_array($obj)) {
                $resource = new Collection($obj, new $transformer(), get_class($obj[0]));
            } else {
                $resource = new Item($obj, new $transformer(), get_class($obj));
            }
        } catch (\Error $e) {
            throw new DWDLibException("Specified transformer is not a class. Got transformer with the class=" . get_class($transformer));
        }
        return $resource;
    }
public static function toResource ( $ obj , $ transformer ) : ResourceAbstract { if ( ! $ obj ) return new NullResource ( ) ; $ resource = null ; try { if ( is_array ( $ obj ) ) { $ resource = new Collection ( $ obj , new $ transformer ( ) , get_class ( $ obj [ 0 ] ) ) ; } else { $ resource = new Item ( $ obj , new $ transformer ( ) , get_class ( $ obj ) ) ; } } catch ( \ Error $ e ) { throw new DWDLibException ( "Specified transformer is not a class. Got transformer with the class=" . get_class ( $ transformer ) ) ; } return $ resource ; }
Transform the given object or array with the given transformer to a Resource.
@param $obj
@param $transformer
@return ResourceAbstract
@throws DWDLibException
Transform the given object or array with the given transformer to a Resource .