Session::terminate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
// Copyright 1999-2021. Plesk International GmbH.
3
4
namespace PleskX\Api\Operator;
5
6
use PleskX\Api\Struct\Session as Struct;
7
8
class Session extends \PleskX\Api\Operator
9
{
10
    /**
11
     * @return Struct\Info[]
12
     */
13
    public function get()
14
    {
15
        $sessions = [];
16
        $response = $this->request('get');
17
18
        foreach ($response->session as $sessionInfo) {
19
            $sessions[(string) $sessionInfo->id] = new Struct\Info($sessionInfo);
20
        }
21
22
        return $sessions;
23
    }
24
25
    /**
26
     * @param string $sessionId
27
     *
28
     * @return bool
29
     */
30
    public function terminate($sessionId)
31
    {
32
        $response = $this->request("terminate.session-id=$sessionId");
33
34
        return 'ok' === (string) $response->status;
35
    }
36
}
37