Completed
Push — master ( c93e0a...f87b82 )
by Mario
09:30 queued 03:59
created

AuthenticationService::getSessionCookie()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 21
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 21
ccs 0
cts 11
cp 0
rs 9.3142
cc 3
eloc 11
nc 3
nop 0
crap 12
1
<?php
2
3
namespace Marek\Toggable\Service\Authentication;
4
5
use Marek\Toggable\API\Http\Request\Authentication\SessionCookie as SessionCookieRequest;
6
use Marek\Toggable\API\Http\Response\Error;
7
use Marek\Toggable\API\Http\Response\Successful;
8
use Marek\Toggable\API\Toggl\AuthenticationServiceInterface;
9
use Marek\Toggable\Service\AbstractService;
10
use Marek\Toggable\API\Security\Cookie\SessionCookie;
11
12
/**
13
 * Class AuthenticationService
14
 * @package Marek\Toggable\Service\Authentication
15
 */
16
class AuthenticationService extends AbstractService implements AuthenticationServiceInterface
17
{
18
    public function getSessionCookie()
19
    {
20
        $request = new SessionCookieRequest();
21
22
        $response = $this->requestManager->request($request);
23
24
        if ($response instanceof Error) {
25
            return $response;
26
        }
27
28
        if (!empty($response->cookie)) {
29
            $sessionCookie = new SessionCookie($response->cookie);
30
31
            $client = $this->requestManager->getHttpClient();
0 ignored issues
show
Bug introduced by
The method getHttpClient() does not seem to exist on object<Marek\Toggable\Ht...equestManagerInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
32
            $client->setCookie($sessionCookie);
33
34
            return new Successful();
35
        }
36
37
        return $response;
38
    }
39
40
    public function destroySession()
41
    {
42
        // TODO: Implement destroySession() method.
43
    }
44
}
45