PretendLinkChecker   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B checkLink() 0 18 10
1
<?php
2
namespace SilverStripe\ExternalLinks\Tests\Stubs;
3
4
use SilverStripe\Dev\TestOnly;
5
use SilverStripe\ExternalLinks\Tasks\LinkChecker;
6
7
class PretendLinkChecker implements LinkChecker, TestOnly
8
{
9
    public function checkLink($href)
10
    {
11
        switch ($href) {
12
            case 'http://www.working.com':
13
                return 200;
14
            case 'http://www.broken.com':
15
                return 403;
16
            case 'http://www.nodomain.com':
17
                return 0;
18
            case '/internal/link':
19
            case '[sitetree_link,id=9999]':
20
            case 'home':
21
            case 'broken-internal':
22
            case '[sitetree_link,id=1]':
23
                return null;
24
            case 'http://www.broken.com/url/thing':
25
            default:
26
                return 404;
27
        }
28
    }
29
}
30