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   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 53
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 2
A format() 0 10 3
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