Base   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
getHttpMethod() 0 1 ?
A getUrl() 0 8 2
A getUrlParts() 0 9 1
1
<?php
2
3
namespace GFG\DTOMarketplace\Context;
4
5
use GFG\DTOUrl\Url;
6
use GFG\DTOContext\Context\Base as BaseContext;
7
use GFG\Hek\Interfaces\Context as ContextInterface;
8
9
abstract class Base extends BaseContext implements ContextInterface
10
{
11
    /**
12
     * @var Url
13
     */
14
    protected $url;
15
16
    /**
17
     * {@inheritdoc}
18
     */
19 1
    public function getUrl()
20
    {
21 1
        if (!$this->url) {
22 1
            $this->url = new Url($this->getUrlParts());
23 1
        }
24
25 1
        return $this->url;
26
    }
27
28
    /**
29
     * Extracts the url information from the current class name and
30
     * namespace
31
     *
32
     * @return array
33
     */
34 1
    protected function getUrlParts()
35
    {
36 1
        $path = array_map(
37 1
            'strtolower',
38 1
            array_slice(preg_split('@\\\\|_@', static::class), -3)
39 1
        );
40
41 1
        return ['httpMethod' => $this->getHttpMethod(), 'path' => $path];
42
    }
43
44
    /**
45
     * Get the http method specific for the context
46
     *
47
     * @return string
48
     */
49
    abstract public function getHttpMethod();
50
}
51