GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( dd13da...b61209 )
by Richard
04:01 queued 54s
created

MySql   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 2
dl 0
loc 57
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A concatenateEscapedFields() 0 4 1
A storeNewTicket() 0 15 2
A fetchPerformerIdByName() 0 14 3
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: wechsler
5
 * Date: 04/10/15
6
 * Time: 21:08
7
 */
8
9
namespace Phase\TakeATicket\DataSource;
10
11
class MySql extends AbstractSql
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16
    protected function concatenateEscapedFields($fields)
17
    {
18
        return 'CONCAT('.implode(', ', $fields).')';
19
    }
20
21
    /**
22
     * Overridden to take advantage of autoIds
23
     *
24
     * @param $title
25
     * @param $songId
26
     *
27
     * @return int|false
28
     */
29
    public function storeNewTicket($title, $songId)
30
    {
31
        $conn = $this->getDbConn();
32
        $max = $conn->fetchAssoc('SELECT max(`offset`) AS o FROM tickets');
33
34
        $maxOffset = $max['o'];
35
        $ticket = [
36
            'title' => $title,
37
            'offset' => $maxOffset + 1,
38
            'songId' => $songId,
39
        ];
40
        $res = $conn->insert(self::TICKETS_TABLE, $ticket);
41
42
        return $res ? $conn->lastInsertId() : false;
0 ignored issues
show
Bug Compatibility introduced by
The expression $res ? $conn->lastInsertId() : false; of type string|false adds the type string to the return on line 42 which is incompatible with the return type of the parent method Phase\TakeATicket\DataSo...ractSql::storeNewTicket of type integer|false.
Loading history...
43
    }
44
45
    /**
46
     * Overridden to take advantage of autoIds
47
     *
48
     * @param $performerName
49
     * @param bool|false    $createMissing
50
     *
51
     * @return mixed
52
     */
53
    public function fetchPerformerIdByName($performerName, $createMissing = false)
54
    {
55
        $conn = $this->getDbConn();
56
        $sql = 'SELECT id FROM performers p WHERE p.name LIKE :name LIMIT 1';
57
        $performerId = $conn->fetchColumn($sql, ['name' => $performerName]);
58
59
        if ($createMissing && !$performerId) {
60
            $conn->insert(self::PERFORMERS_TABLE, ['name' => ucwords($performerName)]);
61
            //add new performer row
62
            $performerId = $conn->lastInsertId();
63
        }
64
65
        return $performerId;
66
    }
67
}
68