. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
| Server IP : 162.0.212.4 / Your IP :
216.73.216.14 [
Web Server : LiteSpeed System : Linux premium146.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64 User : alshnoli ( 2431) PHP Version : 8.3.28 Disable Function : NONE Domains : 1 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/alshnoli/public_html/wp-content/plugins/ameliabooking/src/Infrastructure/ |
Upload File : |
<?php
/**
* @author Slavko Babic
* @date 2017-08-21
*/
namespace AmeliaBooking\Infrastructure;
use mysqli;
use \PDO;
/**
* Class Connection
*
* @package Infrastructure
*/
abstract class Connection
{
/** @var string $username */
protected $username;
/** @var string $password */
protected $password;
/** @var string $charset */
protected $charset;
/** @var PDO|mysqli $handler */
protected $handler;
/** @var int port */
protected $port;
/** @var string $host */
protected $host;
/** @var string $name */
protected $database;
/** @var string $socket */
protected $socket;
/** @var string $socketPath */
protected $socketPath;
/**
* Connection constructor.
*
* @param string $database
* @param string $username
* @param string $password
* @param string $host
* @param int $port
* @param string $charset
*/
public function __construct(
$host,
$database,
$username,
$password,
$charset = 'utf8',
$port = 3306
) {
$this->database = (string)$database;
$this->username = (string)$username;
$this->password = (string)$password;
$this->host = $this->socket = (string)$host;
$this->port = (int)$port;
$this->charset = (string)$charset;
}
/**
* @return PDO|mysqli
*/
public function __invoke()
{
return $this->handler;
}
/**
*
*/
protected function socketHandler()
{
if (strpos($this->socket, ':') === false) {
$this->host = $this->socket;
return;
}
$data = explode(':', $this->socket);
$this->host = $data[0];
if (isset($data[1]) && is_numeric($data[1]) && (int)$data[1]) {
$this->port = $data[1];
} elseif (isset($data[1]) && strpos($data[1], '/') !== false) {
$position = strpos($data[1], '/');
if ($position === 0) {
$this->socketPath = $data[1];
} else {
$this->port = substr($data[1], 0, $position);
$this->socketPath = substr($data[1], $position);
}
} elseif (isset($data[1]) && (int)$data[1]) {
$this->port = $data[1];
}
}
}