protected function toPhpType(array $field, bool $adderOrRemover = false): string
    {
        $range = $field['range'];

        if ($field['isEnum']) {
            if ($field['isArray']) {
                return 'string[]';
            }

            return 'string';
        }

        $data = false;
        switch ($range) {
            case 'Boolean':
                $data = 'bool';
                break;
            case 'Date':
            case 'DateTime':
            case 'Time':
                $data = '\\'.\DateTimeInterface::class;
                break;
            case 'Number':
            case 'Float':
                $data = 'float';
                break;
            case 'Integer':
                $data = 'integer';
                break;
            case 'Text':
            case 'URL':
                $data = 'string';
                break;
        }

        if (false !== $data) {
            if ($field['isArray']) {
                return sprintf('%s[]', $data);
            }

            return $data;
        }

        if (isset($this->classes[$field['range']]['interfaceName'])) {
            $range = $this->classes[$field['range']]['interfaceName'];
        }

        if ($field['isArray'] && !$adderOrRemover) {
            if ($this->config['doctrine']['useCollection']) {
                return sprintf('Collection<%s>', $range);
            }

            return sprintf('%s[]', $range);
        }

        return $range;
    }
protected function toPhpType(array $field, bool $adderOrRemover = false): string
    {
        $range = $field['range'];

        if ($field['isEnum']) {
            if ($field['isArray']) {
                return 'string[]';
            }

            return 'string';
        }

        $data = false;
        switch ($range) {
            case 'Boolean':
                $data = 'bool';
                break;
            case 'Date':
            case 'DateTime':
            case 'Time':
                $data = '\\'.\DateTimeInterface::class;
                break;
            case 'Number':
            case 'Float':
                $data = 'float';
                break;
            case 'Integer':
                $data = 'integer';
                break;
            case 'Text':
            case 'URL':
                $data = 'string';
                break;
        }

        if (false !== $data) {
            if ($field['isArray']) {
                return sprintf('%s[]', $data);
            }

            return $data;
        }

        if (isset($this->classes[$field['range']]['interfaceName'])) {
            $range = $this->classes[$field['range']]['interfaceName'];
        }

        if ($field['isArray'] && !$adderOrRemover) {
            if ($this->config['doctrine']['useCollection']) {
                return sprintf('Collection<%s>', $range);
            }

            return sprintf('%s[]', $range);
        }

        return $range;
    }
protected function toPhpType ( array $ field , bool $ adderOrRemover = false ) : string { $ range = $ field [ 'range' ] ; if ( $ field [ 'isEnum' ] ) { if ( $ field [ 'isArray' ] ) { return 'string[]' ; } return 'string' ; } $ data = false ; switch ( $ range ) { case 'Boolean' : $ data = 'bool' ; break ; case 'Date' : case 'DateTime' : case 'Time' : $ data = '\\' . \ DateTimeInterface :: class ; break ; case 'Number' : case 'Float' : $ data = 'float' ; break ; case 'Integer' : $ data = 'integer' ; break ; case 'Text' : case 'URL' : $ data = 'string' ; break ; } if ( false !== $ data ) { if ( $ field [ 'isArray' ] ) { return sprintf ( '%s[]' , $ data ) ; } return $ data ; } if ( isset ( $ this -> classes [ $ field [ 'range' ] ] [ 'interfaceName' ] ) ) { $ range = $ this -> classes [ $ field [ 'range' ] ] [ 'interfaceName' ] ; } if ( $ field [ 'isArray' ] && ! $ adderOrRemover ) { if ( $ this -> config [ 'doctrine' ] [ 'useCollection' ] ) { return sprintf ( 'Collection<%s>' , $ range ) ; } return sprintf ( '%s[]' , $ range ) ; } return $ range ; }
Converts a Schema.org range to a PHP type.
Converts a Schema . org range to a PHP type .