src/EasyStatement.php
public function sql(): string
    {
        if (empty($this->parts)) {
            return '1';
        }
        return (string) \array_reduce(
            $this->parts,
            function (string $sql, array $part): string {
                /** @var string|self $condition */
                $condition = $part['condition'];

                if ($this->isGroup($condition)) {
                    // (...)
                    if (\is_string($condition)) {
                        $statement = '(' . $condition . ')';
                    } else {
                        $statement = '(' . $condition->sql() . ')';
                    }
                } else {
                    // foo = ?
                    $statement = $condition;
                }
                /** @var string $statement */
                $statement = (string) $statement;
                $part['type'] = (string) $part['type'];

                if ($sql) {
                    switch ($part['type']) {
                        case 'AND':
                        case 'OR':
                            $statement = $part['type'] . ' ' . $statement;
                            break;
                        default:
                            throw new RuntimeException(
                                \sprintf('Invalid joiner %s', $part['type'])
                            );
                    }
                }

                return \trim($sql . ' ' . $statement);
            },
            ''
        );
    }
public function sql(): string
    {
        if (empty($this->parts)) {
            return '1';
        }
        return (string) \array_reduce(
            $this->parts,
            function (string $sql, array $part): string {
                /** @var string|self $condition */
                $condition = $part['condition'];

                if ($this->isGroup($condition)) {
                    // (...)
                    if (\is_string($condition)) {
                        $statement = '(' . $condition . ')';
                    } else {
                        $statement = '(' . $condition->sql() . ')';
                    }
                } else {
                    // foo = ?
                    $statement = $condition;
                }
                /** @var string $statement */
                $statement = (string) $statement;
                $part['type'] = (string) $part['type'];

                if ($sql) {
                    switch ($part['type']) {
                        case 'AND':
                        case 'OR':
                            $statement = $part['type'] . ' ' . $statement;
                            break;
                        default:
                            throw new RuntimeException(
                                \sprintf('Invalid joiner %s', $part['type'])
                            );
                    }
                }

                return \trim($sql . ' ' . $statement);
            },
            ''
        );
    }
public function sql ( ) : string { if ( empty ( $ this -> parts ) ) { return '1' ; } return ( string ) \ array_reduce ( $ this -> parts , function ( string $ sql , array $ part ) : string { /** @var string|self $condition */ $ condition = $ part [ 'condition' ] ; if ( $ this -> isGroup ( $ condition ) ) { // (...) if ( \ is_string ( $ condition ) ) { $ statement = '(' . $ condition . ')' ; } else { $ statement = '(' . $ condition -> sql ( ) . ')' ; } } else { // foo = ? $ statement = $ condition ; } /** @var string $statement */ $ statement = ( string ) $ statement ; $ part [ 'type' ] = ( string ) $ part [ 'type' ] ; if ( $ sql ) { switch ( $ part [ 'type' ] ) { case 'AND' : case 'OR' : $ statement = $ part [ 'type' ] . ' ' . $ statement ; break ; default : throw new RuntimeException ( \ sprintf ( 'Invalid joiner %s' , $ part [ 'type' ] ) ) ; } } return \ trim ( $ sql . ' ' . $ statement ) ; } , '' ) ; }
Compile the current statement into PDO-ready SQL.

@return string
Compile the current statement into PDO - ready SQL .