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.

DbFormatter::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 8
cts 8
cp 1
rs 9.7666
c 0
b 0
f 0
cc 2
nc 1
nop 4
crap 2
1
<?php
2
/**
3
 * Starlit Db.
4
 *
5
 * @copyright Copyright (c) 2016 Starweb AB
6
 * @license   BSD 3-Clause
7
 */
8
9
namespace Starlit\Db\Monolog;
10
11
use Monolog\Formatter\LineFormatter;
12
13
/**
14
 * @author Andreas Nilsson <http://github.com/jandreasn>
15
 */
16
class DbFormatter extends LineFormatter
17
{
18
    /**
19
     * @const string
20
     */
21
    const FORMAT_DEFAULT = "%message% %context% %extra%";
22
23
    /**
24
     * @const int
25
     */
26
    const MAX_LENGTH_DEFAULT = 65535;
27
28
    /**
29
     * @var int
30
     */
31
    protected $maxLength;
32
33
    /**
34
     * @param string|null $format
35
     * @param bool        $allowInlineLineBreaks
36
     * @param bool        $ignoreEmptyContextAndExtra
37
     * @param int         $maxLength
38
     */
39 7
    public function __construct(
40
        $format = null,
41
        $allowInlineLineBreaks = true,
42
        $ignoreEmptyContextAndExtra = true,
43
        $maxLength = self::MAX_LENGTH_DEFAULT
44
    ) {
45 7
        parent::__construct(
46 7
            $format ?: static::FORMAT_DEFAULT,
47 7
            null,
48 7
            $allowInlineLineBreaks,
49 7
            $ignoreEmptyContextAndExtra
50
        );
51
52 7
        $this->maxLength = $maxLength;
53 7
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58 7
    public function format(array $record)
59
    {
60 7
        $output = trim(parent::format($record));
61
62 7
        if ($this->maxLength !== null && strlen($output) > $this->maxLength) {
63 1
            $output = substr($output, 0, $this->maxLength - 3) . '...';
64
        }
65
66 7
        return $output;
67
    }
68
}
69