Urls   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A buildUrl() 0 4 1
A _checkUrlScheme() 0 9 2
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