ProjectFinder::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace MS\Sentry\Monitor\Service\Diagram;
4
5
use Doctrine\DBAL\Connection;
6
7
class ProjectFinder
8
{
9
    /**
10
     * @var Connection
11
     */
12
    private $connection;
13
14
    /**
15
     * @param Connection $connection
16
     */
17
    public function __construct(Connection $connection)
18
    {
19
        $this->connection = $connection;
20
    }
21
22
    /**
23
     * @param string $organisation
24
     * @param string $project
25
     *
26
     * @return array
27
     */
28
    public function getProjects($organisation, $project)
29
    {
30
        if (false === empty($project)) {
31
            return [$project];
32
        }
33
34
        $projects = $this->connection->fetchAll(
35
            'SELECT project FROM events WHERE organisation = ? GROUP BY project',
36
            [$organisation]
37
        );
38
39
        return array_column($projects, 'project');
40
    }
41
}
42