Base::getHttpMethod()
last analyzed

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
c 0
b 0
f 0
ccs 0
cts 0
cp 0
nc 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