ConnectionConfigUrl::__construct()   A
last analyzed

Complexity

Conditions 6
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 6
eloc 7
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 10
rs 9.2222
1
<?php declare(strict_types=1);
2
3
namespace Janisbiz\LightOrm\Dms\MySQL\Connection;
4
5
class ConnectionConfigUrl extends ConnectionConfig
6
{
7
    /**
8
     * @param string $url
9
     */
10
    public function __construct(string $url)
11
    {
12
        $urlParts = \parse_url($url);
13
14
        parent::__construct(
15
            isset($urlParts['host']) ? $urlParts['host'] : '',
16
            isset($urlParts['user']) ? $urlParts['user'] : '',
17
            isset($urlParts['pass']) ? $urlParts['pass'] : '',
18
            isset($urlParts['path']) ? ltrim($urlParts['path'], '/') : '',
19
            isset($urlParts['port']) ? $urlParts['port'] : 3306
20
        );
21
    }
22
}
23