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;
    }