summaryrefslogtreecommitdiff
path: root/vendor/fguillot/picodb/lib/PicoDb/UrlParser.php
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2018-06-21 14:13:41 -0700
committerFrédéric Guillot <fred@kanboard.net>2018-06-21 14:13:41 -0700
commita491348d442ab8e6cd2fa403d4365cdad78e52ce (patch)
treea00f575d82afb2c9051bad95398b4250f4a3d44d /vendor/fguillot/picodb/lib/PicoDb/UrlParser.php
parentc73ac5f1f818b6b21083f6785b4b2f6d778a6496 (diff)
Vendoring deprecated composer libs
Diffstat (limited to 'vendor/fguillot/picodb/lib/PicoDb/UrlParser.php')
-rw-r--r--vendor/fguillot/picodb/lib/PicoDb/UrlParser.php93
1 files changed, 0 insertions, 93 deletions
diff --git a/vendor/fguillot/picodb/lib/PicoDb/UrlParser.php b/vendor/fguillot/picodb/lib/PicoDb/UrlParser.php
deleted file mode 100644
index d8fcaf00..00000000
--- a/vendor/fguillot/picodb/lib/PicoDb/UrlParser.php
+++ /dev/null
@@ -1,93 +0,0 @@
-<?php
-
-namespace PicoDb;
-
-/**
- * Class UrlParser
- *
- * @package PicoDb
- * @author Frederic Guillot
- */
-class UrlParser
-{
- /**
- * URL
- *
- * @access private
- * @var string
- */
- private $url;
-
- /**
- * Constructor
- *
- * @access public
- * @param string $environmentVariable
- */
- public function __construct($environmentVariable = 'DATABASE_URL')
- {
- $this->url = getenv($environmentVariable);
- }
-
- /**
- * Get object instance
- *
- * @access public
- * @param string $environmentVariable
- * @return static
- */
- public static function getInstance($environmentVariable = 'DATABASE_URL')
- {
- return new static($environmentVariable);
- }
-
- /**
- * Return true if the variable is defined
- *
- * @access public
- * @return bool
- */
- public function isEnvironmentVariableDefined()
- {
- return ! empty($this->url);
- }
-
- /**
- * Get settings from URL
- *
- * @access public
- * @param string $url
- * @return array
- */
- public function getSettings($url = '')
- {
- $url = $url ?: $this->url;
- $components = parse_url($url);
-
- if ($components === false) {
- return array();
- }
-
- return array(
- 'driver' => $this->getUrlComponent($components, 'scheme'),
- 'username' => $this->getUrlComponent($components, 'user'),
- 'password' => $this->getUrlComponent($components, 'pass'),
- 'hostname' => $this->getUrlComponent($components, 'host'),
- 'port' => $this->getUrlComponent($components, 'port'),
- 'database' => ltrim($this->getUrlComponent($components, 'path'), '/'),
- );
- }
-
- /**
- * Get URL component
- *
- * @access private
- * @param array $components
- * @param string $component
- * @return mixed|null
- */
- private function getUrlComponent(array $components, $component)
- {
- return ! empty($components[$component]) ? $components[$component] : null;
- }
-}