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.

MySqlConnection::enforcePdoTimezone()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 13
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 2
nop 2
dl 0
loc 13
ccs 6
cts 6
cp 1
crap 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ZsSarkany\LaravelDatabaseStickyTimezone\Connectors;
6
7
use Illuminate\Database\MySqlConnection as BaseMySqlConnection;
8
use ZsSarkany\LaravelDatabaseStickyTimezone\ChangeDetector;
9
10
class MySqlConnection extends BaseMySqlConnection
11
{
12
    use Traits\TimezoneEnforcerTrait;
13
14
    /**
15
     * Enforcing timezone for PDO instance by execution of "SET timezone = xxxx"
16
     * if needed.
17
     *
18
     * @param \PDO|null      $pdo
19
     * @param ChangeDetector $changeDetector
20
     *
21
     * @return \PDO|null
22
     */
23 3
    protected function enforcePdoTimezone(
24
        ?\PDO $pdo,
25
        ChangeDetector $changeDetector
26
    ): ?\PDO {
27 3
        if (is_null($pdo) || $this->pretending()) {
28 1
            return $pdo;
29
        }
30
31
        $changeDetector->handle($pdo, function (string $offset) use ($pdo) {
32 2
            $pdo->exec('SET time_zone = "' . $offset . '"');
33 2
        });
34
35 2
        return $pdo;
36
    }
37
}
38