public function field(string $name, Syntax $value = null)
    {
        if ($value === null) {
            $names = explode('.', $name);
            $syntax = $this;
            foreach ($names as $field) {
                while (method_exists($syntax, 'syntax')) {
                    $syntax = $syntax->syntax();
                }
                if ($syntax instanceof ObjectSyntax && array_key_exists($field, $syntax->fields)) {
                    $syntax = $syntax->fields[$field];
                } else {
                    throw new \InvalidArgumentException("field '{$name}' not found");
                }
            }
            return $syntax;
        }

        $this->fields[$name] = $value;
        return $this;
    }
public function field(string $name, Syntax $value = null)
    {
        if ($value === null) {
            $names = explode('.', $name);
            $syntax = $this;
            foreach ($names as $field) {
                while (method_exists($syntax, 'syntax')) {
                    $syntax = $syntax->syntax();
                }
                if ($syntax instanceof ObjectSyntax && array_key_exists($field, $syntax->fields)) {
                    $syntax = $syntax->fields[$field];
                } else {
                    throw new \InvalidArgumentException("field '{$name}' not found");
                }
            }
            return $syntax;
        }

        $this->fields[$name] = $value;
        return $this;
    }
public function field ( string $ name , Syntax $ value = null ) { if ( $ value === null ) { $ names = explode ( '.' , $ name ) ; $ syntax = $ this ; foreach ( $ names as $ field ) { while ( method_exists ( $ syntax , 'syntax' ) ) { $ syntax = $ syntax -> syntax ( ) ; } if ( $ syntax instanceof ObjectSyntax && array_key_exists ( $ field , $ syntax -> fields ) ) { $ syntax = $ syntax -> fields [ $ field ] ; } else { throw new \ InvalidArgumentException ( "field '{$name}' not found" ) ; } } return $ syntax ; } $ this -> fields [ $ name ] = $ value ; return $ this ; }
Setter and getter of a specific field.

@param  string $name
@param  Tarsana\Syntax\Syntax|null $value
@return Tarsana\Syntax\Syntax|self

@throws InvalidArgumentException
Setter and getter of a specific field .