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.

MySql::storeNewTicket()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 19
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 12
nc 4
nop 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
     * @param null $userId
28
     * @return false|int
29
     */
30
    public function storeNewTicket($title, $songId, $userId = null)
31
    {
32
        $conn = $this->getDbConn();
33
        $max = $conn->fetchAssoc('SELECT max(`offset`) AS o FROM tickets');
34
35
        $maxOffset = $max['o'];
36
        $ticket = [
37
            'title' => $title,
38
            'offset' => $maxOffset + 1,
39
            'songId' => $songId,
40
        ];
41
42
        if ($userId) {
43
            $ticket['createdBy'] = $userId;
44
        }
45
        $res = $conn->insert(self::TICKETS_TABLE, $ticket);
46
47
        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 47 which is incompatible with the return type of the parent method Phase\TakeATicket\DataSo...ractSql::storeNewTicket of type false|integer.
Loading history...
48
    }
49
50
    /**
51
     * Overridden to take advantage of autoIds
52
     *
53
     * @param $performerName
54
     * @param bool|false    $createMissing
55
     *
56
     * @return mixed
57
     */
58
    public function fetchPerformerIdByName($performerName, $createMissing = false)
59
    {
60
        $conn = $this->getDbConn();
61
        $sql = 'SELECT id FROM performers p WHERE p.name LIKE :name LIMIT 1';
62
        $performerId = $conn->fetchColumn($sql, ['name' => $performerName]);
63
64
        if ($createMissing && !$performerId) {
65
            $conn->insert(self::PERFORMERS_TABLE, ['name' => ucwords($performerName)]);
66
            //add new performer row
67
            $performerId = $conn->lastInsertId();
68
        }
69
70
        return $performerId;
71
    }
72
}
73