Conditions | 4 |
Paths | 3 |
Total Lines | 22 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
33 | 5 | public function transform($url, $section) |
|
34 | { |
||
35 | 5 | $http = $this->request->getHttp(); |
|
36 | 5 | $httpSubdomain = $http->getSubdomain(); |
|
37 | 5 | $rootDomain = $http->getRootDomain(); |
|
38 | |||
39 | 5 | $replace = '://' . $section->getSubdomain() . '.' . $rootDomain; |
|
40 | $transform = [ |
||
41 | 5 | '://' . $httpSubdomain . '.' . $rootDomain => $replace, |
|
42 | 5 | '://' . $rootDomain => $replace, |
|
43 | ]; |
||
44 | |||
45 | 5 | foreach ($transform as $search => $replace) { |
|
46 | 5 | $pos = strpos($url, $search); |
|
47 | 5 | if ($pos === false || $pos > 5) { |
|
48 | 5 | continue; |
|
49 | } |
||
50 | 5 | $url = substr_replace($url, '#####', $pos, strlen($search)); |
|
51 | 5 | $url = str_replace('#####', $replace, $url); |
|
52 | } |
||
53 | |||
54 | 5 | return $url; |
|
55 | } |
||
66 |