Urls::_checkUrlScheme()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Richdynamix\PersonalisedProducts\Helper;
4
5
/**
6
 * Class Urls
7
 *
8
 * @category  Richdynamix
9
 * @package   PersonalisedProducts
10
 * @author    Steven Richardson ([email protected]) @mage_gizmo
11
 */
12
class Urls
13
{
14
    /**
15
     * Construct the URL from the correct values stored in the config
16
     *
17
     * @param $url
18
     * @param $port
19
     * @return string
20
     */
21
    public function buildUrl($url, $port)
22
    {
23
        return trim($this->_checkUrlScheme($url), '/') . ":" . $port;
24
    }
25
26
    /**
27
     * Check the admin user has added a URL scheme (default to http://)
28
     *
29
     * @param $url
30
     * @return string
31
     */
32
    private function _checkUrlScheme($url)
33
    {
34
        $parsed = parse_url($url);
35
        if (empty($parsed['scheme'])) {
36
            $url = 'http://' . $url;
37
        }
38
39
        return $url;
40
    }
41
42
}
43