Completed
Push — master ( 9ea506...789ce9 )
by Robbie
13s
created

PretendLinkChecker::checkLink()   B

Complexity

Conditions 10
Paths 10

Size

Total Lines 18
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 10
eloc 16
nc 10
nop 1
dl 0
loc 18
rs 7.2765
c 1
b 0
f 0

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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