Passed
Push — master ( 8b88c7...8cc771 )
by Alex
03:01
created

Service::start()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 19
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 4
nop 6
dl 0
loc 19
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Mezon\Service;
3
4
use Mezon\Security\ProviderInterface;
5
6
/**
7
 * Class Service
8
 *
9
 * @package Mezon
10
 * @subpackage Service
11
 * @author Dodonov A.A.
12
 * @version v.1.0 (2019/08/17)
13
 * @copyright Copyright (c) 2019, aeon.org
14
 */
15
16
/**
17
 * Service class
18
 *
19
 * It bounds together transport, request parameters fetcher, logic, authorization and model
20
 *
21
 * @author Dodonov A.A.
22
 */
23
class Service extends ServiceBase
24
{
25
26
    /**
27
     * Constructor
28
     *
29
     * @param TransportInterface $serviceTransport
30
     *            Service's transport
31
     */
32
    public function __construct(TransportInterface $serviceTransport)
33
    {
34
        try {
35
            parent::__construct($serviceTransport);
36
37
            $this->initCommonRoutes();
38
        } catch (\Exception $e) {
39
            $this->getTransport()->handleException($e);
40
        }
41
    }
42
43
    /**
44
     * Method inits common servoce's routes
45
     */
46
    protected function initCommonRoutes(): void
47
    {
48
        $this->getTransport()->addRoute('/connect/', 'connect', 'POST', 'public_call');
49
        $this->getTransport()->addRoute('/token/[a:token]/', 'setToken', 'POST');
50
        $this->getTransport()->addRoute('/self/id/', 'getSelfId', 'GET');
51
        $this->getTransport()->addRoute('/self/login/', 'getSelfLogin', 'GET');
52
        $this->getTransport()->addRoute('/login-as/', 'loginAs', 'POST');
53
    }
54
}
55