src/Builder/BaseTypeClassBuilder.php
private function buildGeneratedFieldGetter($field_name, $caster, $indent, array &$result)
    {
        $short_getter = null;

        switch ($caster) {
            case ValueCasterInterface::CAST_INT:
                $return_type = 'int';
                break;
            case ValueCasterInterface::CAST_FLOAT:
                $return_type = 'float';
                break;
            case ValueCasterInterface::CAST_BOOL:
                $return_type = 'bool';
                break;
            case ValueCasterInterface::CAST_DATE:
                $return_type = '\\' . DateValueInterface::class;
                break;
            case ValueCasterInterface::CAST_DATETIME:
                $return_type = '\\' . DateTimeValueInterface::class;
                break;
            case ValueCasterInterface::CAST_JSON:
                $return_type = 'mixed';
                break;
            default:
                $return_type = 'string';
        }

        if ($this->useShortGetterName($field_name)) {
            $short_getter = $this->getShortGetterName($field_name);

            $lines[] = '';
            $lines[] = '/**';
            $lines[] = ' * Return value of ' . $field_name . ' field.';
            $lines[] = ' *';
            $lines[] = ' * @return ' . $return_type;
            $lines[] = ' */';
            $lines[] = 'public function ' . $short_getter . '()';
            $lines[] = '{';
            $lines[] = '    return $this->getFieldValue(' . var_export($field_name, true) . ');';
            $lines[] = '}';
        }

        $lines[] = '';
        $lines[] = '/**';
        $lines[] = ' * Return value of ' . $field_name . ' field.';
        $lines[] = ' *';
        $lines[] = ' * @return ' . $return_type;

        if ($short_getter && $this->getStructure()->getConfig('deprecate_long_bool_field_getter')) {
            $lines[] = " * @deprecated use $short_getter()";
        }

        $lines[] = ' */';
        $lines[] = 'public function ' . $this->getGetterName($field_name) . '()';
        $lines[] = '{';
        $lines[] = '    return $this->getFieldValue(' . var_export($field_name, true) . ');';
        $lines[] = '}';
        $lines[] = '';

        foreach ($lines as $line) {
            $result[] = $line ? $indent . $line : '';
        }
    }
private function buildGeneratedFieldGetter($field_name, $caster, $indent, array &$result)
    {
        $short_getter = null;

        switch ($caster) {
            case ValueCasterInterface::CAST_INT:
                $return_type = 'int';
                break;
            case ValueCasterInterface::CAST_FLOAT:
                $return_type = 'float';
                break;
            case ValueCasterInterface::CAST_BOOL:
                $return_type = 'bool';
                break;
            case ValueCasterInterface::CAST_DATE:
                $return_type = '\\' . DateValueInterface::class;
                break;
            case ValueCasterInterface::CAST_DATETIME:
                $return_type = '\\' . DateTimeValueInterface::class;
                break;
            case ValueCasterInterface::CAST_JSON:
                $return_type = 'mixed';
                break;
            default:
                $return_type = 'string';
        }

        if ($this->useShortGetterName($field_name)) {
            $short_getter = $this->getShortGetterName($field_name);

            $lines[] = '';
            $lines[] = '/**';
            $lines[] = ' * Return value of ' . $field_name . ' field.';
            $lines[] = ' *';
            $lines[] = ' * @return ' . $return_type;
            $lines[] = ' */';
            $lines[] = 'public function ' . $short_getter . '()';
            $lines[] = '{';
            $lines[] = '    return $this->getFieldValue(' . var_export($field_name, true) . ');';
            $lines[] = '}';
        }

        $lines[] = '';
        $lines[] = '/**';
        $lines[] = ' * Return value of ' . $field_name . ' field.';
        $lines[] = ' *';
        $lines[] = ' * @return ' . $return_type;

        if ($short_getter && $this->getStructure()->getConfig('deprecate_long_bool_field_getter')) {
            $lines[] = " * @deprecated use $short_getter()";
        }

        $lines[] = ' */';
        $lines[] = 'public function ' . $this->getGetterName($field_name) . '()';
        $lines[] = '{';
        $lines[] = '    return $this->getFieldValue(' . var_export($field_name, true) . ');';
        $lines[] = '}';
        $lines[] = '';

        foreach ($lines as $line) {
            $result[] = $line ? $indent . $line : '';
        }
    }
private function buildGeneratedFieldGetter ( $ field_name , $ caster , $ indent , array & $ result ) { $ short_getter = null ; switch ( $ caster ) { case ValueCasterInterface :: CAST_INT : $ return_type = 'int' ; break ; case ValueCasterInterface :: CAST_FLOAT : $ return_type = 'float' ; break ; case ValueCasterInterface :: CAST_BOOL : $ return_type = 'bool' ; break ; case ValueCasterInterface :: CAST_DATE : $ return_type = '\\' . DateValueInterface :: class ; break ; case ValueCasterInterface :: CAST_DATETIME : $ return_type = '\\' . DateTimeValueInterface :: class ; break ; case ValueCasterInterface :: CAST_JSON : $ return_type = 'mixed' ; break ; default : $ return_type = 'string' ; } if ( $ this -> useShortGetterName ( $ field_name ) ) { $ short_getter = $ this -> getShortGetterName ( $ field_name ) ; $ lines [ ] = '' ; $ lines [ ] = '/**' ; $ lines [ ] = ' * Return value of ' . $ field_name . ' field.' ; $ lines [ ] = ' *' ; $ lines [ ] = ' * @return ' . $ return_type ; $ lines [ ] = ' */' ; $ lines [ ] = 'public function ' . $ short_getter . '()' ; $ lines [ ] = '{' ; $ lines [ ] = '    return $this->getFieldValue(' . var_export ( $ field_name , true ) . ');' ; $ lines [ ] = '}' ; } $ lines [ ] = '' ; $ lines [ ] = '/**' ; $ lines [ ] = ' * Return value of ' . $ field_name . ' field.' ; $ lines [ ] = ' *' ; $ lines [ ] = ' * @return ' . $ return_type ; if ( $ short_getter && $ this -> getStructure ( ) -> getConfig ( 'deprecate_long_bool_field_getter' ) ) { $ lines [ ] = " * @deprecated use $short_getter()" ; } $ lines [ ] = ' */' ; $ lines [ ] = 'public function ' . $ this -> getGetterName ( $ field_name ) . '()' ; $ lines [ ] = '{' ; $ lines [ ] = '    return $this->getFieldValue(' . var_export ( $ field_name , true ) . ');' ; $ lines [ ] = '}' ; $ lines [ ] = '' ; foreach ( $ lines as $ line ) { $ result [ ] = $ line ? $ indent . $ line : '' ; } }
Build getter for generated field.

@param string $field_name
@param string $caster
@param string $indent
@param array  $result
Build getter for generated field .