Completed
Push — master ( b8a8af...689cd9 )
by Mark
04:55
created

UserAgentTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 62.07 %

Coupling/Cohesion

Components 1
Dependencies 2
Metric Value
wmc 5
lcom 1
cbo 2
dl 18
loc 29
rs 10

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
class UserAgentTest extends PHPUnit_Framework_TestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
    protected $CrawlerDetect;
6
7
    public function setUp()
8
    {
9
        $this->CrawlerDetect = new Jaybizzle\CrawlerDetect\CrawlerDetect();
10
    }
11
12
    public function testBots()
13
    {
14
        $lines = file(__DIR__.'/crawlers.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES));
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected ')'
Loading history...
15
16
        foreach ($lines as $line) {
17
            $test = $this->CrawlerDetect->isCrawler($line);
18
            $this->assertEquals($test, true, $line);
19
        }
20
    }
21
22
    public function testDevices()
23
    {
24
        $lines = file(__DIR__.'/devices.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES));
25
26
        foreach ($lines as $line) {
27
            $test = $this->CrawlerDetect->isCrawler($line);
28
            $this->assertEquals($test, false, $line);
29
        }
30
    }
31
}
32