Completed
Pull Request — development (#560)
by Thomas
06:46
created

Reports   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getReportStatus() 0 15 1
1
<?php
2
3
namespace Oc\GeoCache;
4
5
use Doctrine\DBAL\Connection;
6
7
class Reports
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 array $wpCodes
24
     * @return array
25
     */
26
    public function getReportStatus(array $wpCodes)
27
    {
28
        $query = $this->connection->createQueryBuilder()
29
            ->select('DISTINCT(wp_oc)')
30
            ->from('caches', 'c')
31
            ->innerJoin('c', 'cache_reports', 'cr', 'cr.cacheid = c.cache_id')
32
            ->where('wp_oc IN (:wpCodes)')
33
            ->andWhere('cr.status IN (:status)')
34
            ->setParameter(':wpCodes', $wpCodes, Connection::PARAM_STR_ARRAY)
35
            ->setParameter(':status', [1, 2], Connection::PARAM_INT_ARRAY);
36
37
        $statement = $query->execute();
38
39
        return $statement->fetchAll(\PDO::FETCH_ASSOC);
40
    }
41
}
42