Passed
Push — phpunit8 ( f24111 )
by Sam
08:30
created

UrlPathStartswithCaseInsensitive   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 8
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 8
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A checkPath() 0 6 1
1
<?php
2
3
namespace SilverStripe\Control\Middleware\ConfirmationMiddleware;
4
5
use SilverStripe\Control\HTTPRequest;
6
use SilverStripe\Security\Confirmation;
7
8
/**
9
 * A case insensitive rule to match beginning of URL
10
 */
11
class UrlPathStartswithCaseInsensitive extends UrlPathStartswith
12
{
13
    protected function checkPath($path)
14
    {
15
        $pattern = $this->getPath();
16
17
        $mb_path = mb_strcut($this->normalisePath($path), 0, strlen($pattern));
18
        return mb_stripos($mb_path, $pattern) === 0;
19
    }
20
}
21