Completed
Push — master ( 3cf617...93247c )
by Saurabh
08:56
created

AdjustUrl::transformUrl()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 3.1406

Importance

Changes 0
Metric Value
cc 3
eloc 4
nc 2
nop 2
dl 0
loc 8
ccs 3
cts 4
cp 0.75
crap 3.1406
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Sausin\Signere;
4
5
trait AdjustUrl
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 4
    protected function transformUrl(string $url, string $prefix = 'test')
15
    {
16 4
        if ($this->environment === 'test' || $this->environment === 'local') {
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
            return http_build_url($exploded, $prefix.parse_url($url)['host']);
0 ignored issues
show
Bug introduced by
The variable $exploded does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
18
        }
19
20 4
        return $url;
21
    }
22
}
23