ProjectFinder   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 35
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getProjects() 0 13 2
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