Bitly::handle()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 9

Duplication

Lines 16
Ratio 100 %

Code Coverage

Tests 7
CRAP Score 3.0175

Importance

Changes 0
Metric Value
dl 16
loc 16
ccs 7
cts 8
cp 0.875
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 9
nc 3
nop 3
crap 3.0175
1
<?php
2
3
namespace LeadThread\Shortener\Rotators\Account;
4
5
use Exception;
6
use LeadThread\Bitly\Bitly as BitlyDriver;
7
use LeadThread\Shortener\Exceptions\ShortenerException;
8
9 View Code Duplication
class Bitly extends Rotator
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
{
11 18
    protected function handle($driver, $url, $encode)
12
    {
13 18
        $short = false;
14
15 18
        if(!$driver instanceof BitlyDriver){
16
            throw new Exception("Incorrect Driver! ".get_class($driver));
17
        }
18
19
        try{
20 18
            $short = $driver->shorten($url, $encode);
21 18
        } catch (Exception $e) {
22 9
            $this->error = $e->getMessage();
23
        }
24
25 18
        return $short;
26
    }
27
}