Environment   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 42
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
getWsHost() 0 1 ?
getHost() 0 1 ?
A isValid() 0 4 1
A getWsUrl() 0 4 1
A getUrl() 0 4 1
1
<?php
2
namespace PHPSC\PagSeguro;
3
4
use PHPSC\PagSeguro\Environments\Production;
5
use PHPSC\PagSeguro\Environments\Sandbox;
6
7
/**
8
 * @author Luís Otávio Cobucci Oblonczyk <[email protected]>
9
 */
10
abstract class Environment
11
{
12
    /**
13
     * @param string $host
14
     *
15
     * @return boolean
16
     */
17 3
    public static function isValid($host)
18
    {
19 3
        return in_array($host, [Production::WS_HOST, Sandbox::WS_HOST]);
20
    }
21
22
    /**
23
     * @param string $resource
24
     *
25
     * @return string
26
     */
27 5
    public function getWsUrl($resource)
28
    {
29 5
        return 'https://' . $this->getWsHost() . $resource;
30
    }
31
32
    /**
33
     * @param string $resource
34
     *
35
     * @return string
36
     */
37 3
    public function getUrl($resource)
38
    {
39 3
        return 'https://' . $this->getHost() . $resource;
40
    }
41
42
    /**
43
     * @return string
44
     */
45
    abstract public function getWsHost();
46
47
    /**
48
     * @return string
49
     */
50
    abstract public function getHost();
51
}
52