"Fossies" - the Fresh Open Source Software Archive

Member "papayacms-core-6.9.4/src/system/Papaya/Database/Schema/AbstractSchema.php" (13 Dec 2019, 1180 Bytes) of package /linux/www/papayacms-core-6.9.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "AbstractSchema.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 namespace Papaya\Database\Schema {
    4 
    5   use Papaya\Database\Connection;
    6   use Papaya\Database\Schema;
    7 
    8   abstract class AbstractSchema implements Schema {
    9 
   10     /**
   11      * @var Connection
   12      */
   13     protected $_connection;
   14 
   15     public function __construct(Connection $connection) {
   16       $this->_connection = $connection;
   17     }
   18 
   19     protected function getIdentifier($name, $prefix = '') {
   20       if (trim($prefix) !== '') {
   21         $result = trim($prefix).'_'.trim($name);
   22       } else {
   23         $result = trim($name);
   24       }
   25       $result = strtolower($result);
   26       if (!preg_match('(^[a-z\\d_ ]+$)D', $result)) {
   27         throw new \InvalidArgumentException(
   28           "Invalid identifier name: $result"
   29         );
   30       }
   31       return $result;
   32     }
   33 
   34     protected function getQuotedIdentifier($name, $prefix = '') {
   35       return $this->_connection->quoteIdentifier($this->getIdentifier($name, $prefix));
   36     }
   37 
   38     protected function getQuotedIdentifiers($names, $prefix = '') {
   39       $result = [];
   40       foreach ($names as $name) {
   41         $result[] = $this->_connection->quoteIdentifier($this->getIdentifier($name, $prefix));
   42       }
   43       return $result;
   44     }
   45   }
   46 }