protected function getJoins(array $queryParts)
    {
        $result = null;

        if (isset($queryParts['join']) && !empty($queryParts['join'])) {
            $result = [];

            foreach ($queryParts['join'] as $join) {
                $piece = trim($join[0] . ' JOIN') . ' ';
                $piece .= is_a($join[1], 'Database\Table') ?
                    sprintf(
                        '%s AS %s',
                        $this->quoteTable($join[1]->getTable()),
                        $this->quoteTable($join[1]->getName())
                    ) :
                    (string)$join[1];
                $piece .= ' ON ' . $join[2];
                $result[] = $piece;
            }

            $result = implode(' ', $result);
        }

        return $result;
    }