Completed
Push — master ( b97427...e235cc )
by Raffael
30:35 queued 26:08
created

Hosts   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 32
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 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\HostManager;
15
use Micro\Http\Response;
16
17
class Hosts
18
{
19
    /**
20
     * Host manager.
21
     *
22
     * @var HostManager
23
     */
24
    protected $manager;
25
26
    /**
27
     * Constructor.
28
     */
29
    public function __construct(HostManager $manager)
30
    {
31
        $this->manager = $manager;
32
    }
33
34
    /**
35
     * Get wopi hosts.
36
     */
37
    public function get(): Response
38
    {
39
        $hosts = $this->manager->getHosts();
40
        $body = [
41
            'total' => count($hosts),
42
            'count' => count($hosts),
43
            'data' => $hosts,
44
        ];
45
46
        return (new Response())->setCode(200)->setBody($body);
47
    }
48
}
49