| Total Complexity | 8 |
| Total Lines | 64 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | class DBDriver implements IpCheckerInterface{ |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Model for saving logs |
||
| 19 | * |
||
| 20 | * @var [type] |
||
|
|
|||
| 21 | */ |
||
| 22 | protected $model; |
||
| 23 | protected $ipList = []; |
||
| 24 | |||
| 25 | public function __construct(IpList $ipList) |
||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @return array |
||
| 32 | */ |
||
| 33 | public function getIpArray() |
||
| 34 | { |
||
| 35 | foreach ($this->model->all() as $record){ |
||
| 36 | array_push($this->ipList,$record->ip); |
||
| 37 | } |
||
| 38 | $ipList = $this->ipList ?? []; |
||
| 39 | |||
| 40 | return $ipList; |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @return IpList[]|\Illuminate\Database\Eloquent\Collection|mixed |
||
| 45 | */ |
||
| 46 | public function getIpList() |
||
| 47 | { |
||
| 48 | return $this->model->all(); |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @param $array |
||
| 53 | * @return bool |
||
| 54 | */ |
||
| 55 | public function saveIp($array) |
||
| 56 | { |
||
| 57 | $result = IpList::create($array); |
||
| 58 | if (!$result){ |
||
| 59 | return false; |
||
| 60 | } |
||
| 61 | |||
| 62 | return true; |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * @param $ipAddress |
||
| 67 | * @return bool |
||
| 68 | */ |
||
| 69 | public function deleteIp($ipAddress) |
||
| 79 | } |
||
| 80 | } |