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.

PlaceholderUtil   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isValidPlaceholder() 0 8 3
A isValidPlaceholderOrThrowException() 0 8 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace espend\Behat\PlaceholderExtension\Utils;
5
6
/**
7
 * @author Daniel Espendiller <[email protected]>
8
 */
9
final class PlaceholderUtil
10
{
11
    /**
12
     * @param string $placeholder
13
     * @return bool
14
     */
15 31
    public static function isValidPlaceholder(string $placeholder): bool
16
    {
17
        return
18 31
            isset($placeholder[0]) &&
19 31
            $placeholder[0] === '%' &&
20 31
            $placeholder[strlen($placeholder) - 1] === '%'
21
        ;
22
    }
23
24
    /**
25
     * @param string $placeholder
26
     */
27 27
    public static function isValidPlaceholderOrThrowException(string $placeholder)
28
    {
29 27
        if (!static::isValidPlaceholder($placeholder)) {
30 5
            throw new \RuntimeException(
31 5
                'Invalid placeholder given; please wrap your placeholder with a percent sign %foobar%'
32
            );
33
        }
34 22
    }
35
}
36