Code Duplication    Length = 16-19 lines in 2 locations

src/Rotators/Account/Bitly.php 1 location

@@ 9-27 (lines=19) @@
6
use LeadThread\Bitly\Bitly as BitlyDriver;
7
use LeadThread\Shortener\Exceptions\ShortenerException;
8
9
class Bitly extends Rotator
10
{
11
    protected function handle($driver, $url, $encode)
12
    {
13
        $short = false;
14
15
        if(!$driver instanceof BitlyDriver){
16
            throw new Exception("Incorrect Driver! ".get_class($driver));
17
        }
18
19
        try{
20
            $short = $driver->shorten($url, $encode);
21
        } catch (Exception $e) {
22
            $this->error = $e->getMessage();
23
        }
24
25
        return $short;
26
    }
27
}

src/Rotators/Account/Google.php 1 location

@@ 9-24 (lines=16) @@
6
use LeadThread\GoogleShortener\Google as GoogleDriver;
7
use LeadThread\Shortener\Exceptions\ShortenerException;
8
9
class Google extends Rotator
10
{
11
    protected function handle($driver, $url, $encode)
12
    {
13
        $short = false;
14
        if(!$driver instanceof GoogleDriver){
15
            throw new Exception("Incorrect Driver! ".get_class($driver));
16
        }
17
        try{
18
            $short = $driver->shorten($url, $encode);
19
        } catch (Exception $e) {
20
            $this->error = $e->getMessage();
21
        }
22
        return $short;
23
    }
24
}