Completed
Push — master ( 53c3c6...647838 )
by Xinjiang
03:18
created

FakeConnection   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 31
wmc 5
lcom 1
cbo 0
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A lookup() 0 4 1
A reverseLookup() 0 5 1
A addNewRecord() 0 4 1
A getIncrementUid() 0 4 1
1
<?php
2
3
namespace Soleo\UrlShortener;
4
5
class FakeConnection implements ConnectionInterface
6
{
7
    private $fakeDB;
8
    public function __construct($config = null)
0 ignored issues
show
Unused Code introduced by
The parameter $config is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
9
    {
10
        $this->fakeDB = [
11
            'A9A' => 'https://example.com'
12
        ];
13
    }
14
15
    public function lookup($slug, $update)
16
    {
17
        return $this->fakeDB[$slug];
18
    }
19
20
    public function reverseLookup($longUrl)
21
    {
22
        $reversedArray = array_flip($this->fakeDB);
23
        return $reversedArray[$longUrl];
24
    }
25
26
    public function addNewRecord($longUrl, $slug)
27
    {
28
        return true;
29
    }
30
31
    public function getIncrementUid()
32
    {
33
        return 1;
34
    }
35
}
36