Passed
Pull Request — master (#374)
by Tim
11:54 queued 09:21
created

GeolocationTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A validGeolocation() 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\Exception\ProtocolViolationException;
9
10
/**
11
 * @package simplesamlphp/saml2
12
 */
13
trait GeolocationTrait
14
{
15
    // @TODO: this regex is incomplete, so reverting to the default URI-check
16
    //private static string $geolocation_regex = '/^geo:([-+]?\d+(?:\.\d+)?),([-+]?\d+(?:\.\d+)?)(?:\?z=(\d{1,2}))?$/';
17
18
    /**
19
     * @param string $value
20
     * @param string $message
21
     */
22
    protected static function validGeolocation(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 validGeolocation(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
        // Assert::regex(
25
        //     $value,
26
        //     '/^geo:([-+]?\d+(?:\.\d+)?),([-+]?\d+(?:\.\d+)?)(?:\?z=(\d{1,2}))?$/',
27
        //     'Content is not a valid geolocation:  %s'
28
        // );
29
        // The regex above is incomplete, so for now we only test for a valid URI
30
31
        try {
32
            static::validAnyURI($value);
33
        } catch (AssertionFailedException $e) {
34
            throw new ProtocolViolationException($e->getMessage());
35
        }
36
    }
37
}
38