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

EntityIDTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 19
rs 10
c 1
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A validEntityID() 0 13 2
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