public function cast($value)
    {
        if ($value === null) {
            return null;
        }

        $fn = 'cast' . ucfirst(gettype($value));

        switch (strtolower($this->class)) {
            case '':
                return $this->castToObject($value);
            case 'stdclass':
                return $this->castToStdClass($value);
            default:
                return $this->castToClass($value);
        }
    }