Completed
Branch develop-3.0 (4fe777)
by Mohamed
11:06
created

RepositoryUpdater   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 55
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A save() 0 4 1
A delete() 0 4 1
A create() 0 5 1
A update() 0 4 1
A transaction() 0 7 1
1
<?php
2
/*
3
 * This file is part of the site package.
4
 *
5
 * (c) Mohamed Alsharaf <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Tinyissue\Repository;
12
13
use DB;
14
use Illuminate\Database\Eloquent\Model;
15
use Tinyissue\Extensions\Auth\LoggedUser;
16
17
abstract class RepositoryUpdater
18
{
19
    use LoggedUser;
20
21
    /**
22
     * @var Model
23
     */
24
    protected $model;
25
26
    public function __construct(Model $model)
27
    {
28
        $this->model = $model;
29
    }
30
31
    public function save(array $options = [])
32
    {
33
        return $this->model->save($options);
34
    }
35
36
    public function delete()
37
    {
38
        return $this->model->delete();
39
    }
40
41
    /**
42
     * @param array $data
43
     *
44
     * @return mixed
45
     */
46
    public function create(array $data)
47
    {
48
        return $this->save($data);
49
        // TODO: Implement create() method.
50
    }
51
52
    /**
53
     * @param array $data
0 ignored issues
show
Bug introduced by
There is no parameter named $data. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
54
     * @param $id
55
     * @param string $attribute
0 ignored issues
show
Documentation introduced by
There is no parameter named $attribute. Did you maybe mean $attributes?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
56
     *
57
     * @return mixed
58
     */
59
    public function update(array $attributes = [], array $options = [])
60
    {
61
        return $this->model->update($attributes, $options);
62
    }
63
64
    protected function transaction($method)
65
    {
66
        return DB::transaction([$this, $method]);
67
//        DB::transaction(function () use ($method) {
68
//            return $this->$method();
69
//        });
70
    }
71
}
72