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

AdjustUrl   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 3
cts 4
cp 0.75
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A transformUrl() 0 8 3
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