Passed
Pull Request — master (#374)
by Tim
02:48
created

EntityIDTrait::validEntityID()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 9
nc 3
nop 2
dl 0
loc 13
rs 9.9666
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\SAML2\Assert;
6
7
use SimpleSAML\Assert\AssertionFailedException;
8
use SimpleSAML\SAML2\Constants as C;
9
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
10
11
use function sprintf;
12
13
/**
14
 * @package simplesamlphp/saml2
15
 */
16
trait EntityIDTrait
17
{
18
    /**
19
     * @param string $value
20
     * @param string $message
21
     */
22
    protected static function validEntityID(string $value, string $message = ''): void
0 ignored issues
show
Unused Code introduced by
The parameter $message is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

22
    protected static function validEntityID(string $value, /** @scrutinizer ignore-unused */ string $message = ''): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
23
    {
24
        static::validSAMLAnyURI($value);
25
26
        try {
27
            parent::notWhitespaceOnly($value);
28
            parent::maxLength(
29
                $value,
30
                C::ENTITYID_MAX_LENGTH,
31
                sprintf('An entityID cannot be longer than %d characters.', C::ENTITYID_MAX_LENGTH),
32
            );
33
        } catch (AssertionFailedException $e) {
34
            throw new ProtocolViolationException($e->getMessage());
35
        }
36
    }
37
}
38