Completed
Push — master ( f98365...7d52cd )
by Saurabh
10:18
created

UrlTransformer::transformUrl()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 5
nc 2
nop 2
dl 0
loc 10
ccs 5
cts 5
cp 1
crap 4
rs 9.2
c 0
b 0
f 0
1
<?php
2
3
namespace Sausin\Signere\Concerns;
4
5
trait UrlTransformer
6
{
7
    /**
8
     * Adjust the URL to production or test environment.
9
     *
10
     * @param  string $url
11
     * @param  string $prefix
12
     * @return string
13
     */
14 78
    protected function transformUrl(string $url, string $prefix = 'test')
15
    {
16 78
        $check = $this->environment;
0 ignored issues
show
Bug introduced by
The property environment does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
17
18 78
        if ($check === 'test' || $check === 'local' || $check === 'testing') {
19 16
            return http_build_url($url, ['host' => $prefix.parse_url($url)['host']]);
20
        }
21
22 62
        return $url;
23
    }
24
}
25