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.

Capturer   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 1
dl 0
loc 57
ccs 21
cts 21
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 8 2
A getContentKey() 0 4 1
A start() 0 5 1
A end() 0 11 2
A getContent() 0 12 3
1
<?php declare(strict_types=1);
2
/**
3
 * Starlit App.
4
 *
5
 * @copyright Copyright (c) 2016 Starweb AB
6
 * @license   BSD 3-Clause
7
 */
8
9
namespace Starlit\App\ViewHelper;
10
11
class Capturer extends AbstractViewHelper
12
{
13
    /**
14
     * @var array
15
     */
16
    protected $capturedContent = [];
17
18
    /**
19
     * @var string
20
     */
21
    protected $activeContentKey;
22
23 4
    public function __invoke(string $contentKey = null): AbstractViewHelper
24
    {
25 4
        if ($contentKey !== null) {
26 4
            $this->activeContentKey = $contentKey;
27
        }
28
29 4
        return $this;
30
    }
31
32 1
    public function getContentKey(): string
33
    {
34 1
        return $this->activeContentKey;
35
    }
36
37 4
    public function start(): void
38
    {
39
        // Start capturing
40 4
        \ob_start();
41 4
    }
42
43 3
    public function end(): AbstractViewHelper
44
    {
45 3
        if (empty($this->activeContentKey)) {
46 1
            throw new \LogicException('Specify view helper Capturer\'s content key for ending capture');
47
        }
48
49
        // Get the captured contents and end this output buffer
50 2
        $this->capturedContent[$this->activeContentKey] = \ob_get_clean();
51
52 2
        return $this;
53
    }
54
55 4
    public function getContent(): string
56
    {
57 4
        if (empty($this->activeContentKey)) {
58 1
            throw new \LogicException('Specify view helper Capturer\'s content key for getting content');
59
        }
60 3
        if (!isset($this->capturedContent[$this->activeContentKey])) {
61 1
            $errorMsg = "View helper Capturer does not have any content for key \"{$this->activeContentKey}\"";
62 1
            throw new \LogicException($errorMsg);
63
        }
64
65 2
        return $this->capturedContent[$this->activeContentKey];
66
    }
67
}
68