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.

Shortcode::__construct()   A
last analyzed

Complexity

Conditions 5
Paths 3

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 10
cts 10
cp 1
rs 9.3554
c 0
b 0
f 0
cc 5
nc 3
nop 4
crap 5
1
<?php
2
namespace Thunder\Shortcode\Shortcode;
3
4
/**
5
 * @author Tomasz Kowalczyk <[email protected]>
6
 */
7
final class Shortcode extends AbstractShortcode implements ShortcodeInterface
8
{
9
    /**
10
     * @param string $name
11
     * @param array $parameters
12
     * @psalm-param array<string,string|null> $parameters
13
     * @param string|null $content
14
     * @param string|null $bbCode
15
     */
16 227
    public function __construct($name, array $parameters, $content, $bbCode = null)
17
    {
18
        /** @psalm-suppress RedundantConditionGivenDocblockType, DocblockTypeContradiction */
19 227
        if(false === is_string($name) || '' === $name) {
20 1
            throw new \InvalidArgumentException('Shortcode name must be a non-empty string!');
21
        }
22
23
        /** @psalm-suppress MissingClosureParamType, MissingClosureReturnType */
24
        $isStringOrNull = function($value) { return is_string($value) || null === $value; };
25 226
        if(count(array_filter($parameters, $isStringOrNull)) !== count($parameters)) {
26 1
            throw new \InvalidArgumentException('Parameter values must be either string or empty (null)!');
27
        }
28
29 225
        $this->name = $name;
30 225
        $this->parameters = $parameters;
31 225
        $this->content = $content;
32 225
        $this->bbCode = $bbCode;
33 225
    }
34
35 1
    public function withContent($content)
36
    {
37 1
        return new self($this->name, $this->parameters, $content, $this->bbCode);
38
    }
39
}
40