LotDeliveryPaymentRepository   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 36
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getModel() 0 4 1
A save() 0 19 4
1
<?php
2
3
namespace App\Repositories;
4
5
use App\LotDeliveryPayment;
6
7
class LotDeliveryPaymentRepository extends Repository
8
{
9
    /**
10
     * @return Banner
11
     */
12
    public function getModel()
13
    {
14
        return new LotDeliveryPayment();
15
    }
16
17
    /**
18
     * Get ad-blocks for extended banners block.
19
     *
20
     * @param $count
21
     * @return mixed
22
     */
23
    public function save($lot, array $data)
24
    {
25
        $model = self::getModel();
26
        $model->where('lot_id', $lot->id)->delete();
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<App\LotDeliveryPayment>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
27
        $insert = []; $i = 0;
28
        if (!empty($data)) {
29
            foreach ($data as $key1 => $method) {
30
                foreach ($method as $key2 => $item) {
31
                    $insert[$i]['lot_id']      = $lot->id;
32
                    $insert[$i]['method_id']   = (int)$item;
33
                    $insert[$i]['method_type'] = $key1;
34
                    $i++;
35
                }
36
37
            }
38
            $model->insert($insert);
0 ignored issues
show
Bug introduced by
The method insert() does not exist on App\LotDeliveryPayment. Did you maybe mean insertAndSetId()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
39
        }
40
        return true;
41
    }
42
}