Test Failed
Pull Request — master (#350)
by Raffael
26:39
created

Tokens   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 6
dl 0
loc 40
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A post() 0 11 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * balloon
7
 *
8
 * @copyright   Copryright (c) 2012-2019 gyselroth GmbH (https://gyselroth.com)
9
 * @license     GPL-3.0 https://opensource.org/licenses/GPL-3.0
10
 */
11
12
namespace Balloon\App\Wopi\Api\v2;
13
14
use Balloon\App\Wopi\SessionManager;
15
use Balloon\Filesystem;
16
use Balloon\Server;
17
use Micro\Http\Response;
18
19
class Tokens
20
{
21
    /**
22
     * Session manager.
23
     *
24
     * @var SessionManager
25
     */
26
    protected $manager;
27
28
    /**
29
     * Filesystem.
30
     *
31
     * @var Filesystem
32
     */
33
    protected $fs;
34
35
    /**
36
     * Constructor.
37
     */
38
    public function __construct(Server $server, SessionManager $manager)
39
    {
40
        $this->fs = $server->getFilesystem();
41
        $this->manager = $manager;
42
    }
43
44
    /**
45
     * Create session.
46
     */
47
    public function post(string $id): Response
48
    {
49
        $node = $this->fs->getNode($id);
50
        $session = $this->manager->create($node, $this->fs->getUser());
0 ignored issues
show
Compatibility introduced by
$node of type object<Balloon\Filesystem\Node\NodeInterface> is not a sub-type of object<Balloon\Filesystem\Node\File>. It seems like you assume a concrete implementation of the interface Balloon\Filesystem\Node\NodeInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
51
52
        return (new Response())->setCode(201)->setBody([
53
            'node' => (string) $node->getId(),
54
            'access_token' => $session->getAccessToken(),
55
            'ttl' => $session->getAccessTokenTTL(),
56
        ]);
57
    }
58
}
59