Example #1
0
 /**
  * Constructor.
  * 
  * @param \WordPress\Database\Connection $connection
  * @param string $table_name
  * 
  * @throws \InvalidArgumentException if $table_name is not a string.
  */
 public function __construct(Connection $connection, $table_name)
 {
     if (!is_string($table_name)) {
         throw new InvalidArgumentException("Expecting string for 'table_name', given: " . gettype($table_name));
     }
     $this->connection = $connection;
     $this->tableName = $this->connection->maybeAddTablePrefix($table_name);
     if ($this->tableName !== $table_name) {
         // prefix was added
         $this->name = $table_name;
     } else {
         // $table_name is prefixed
         $this->name = $this->connection->stripTablePrefix($table_name);
     }
 }