FakeModel   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 3
Bugs 1 Features 1
Metric Value
wmc 7
c 3
b 1
f 1
lcom 1
cbo 0
dl 0
loc 57
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 3
A setup() 0 19 4
1
<?php namespace Mascame\Artificer\Model;
2
3
/**
4
 * Allows to make calls to tables that dont have Model
5
 *
6
 * Class FakeModel
7
 * @package Mascame\Artificer\Model
8
 */
9
class FakeModel extends \Eloquent
10
{
11
12
    /**
13
     * @var
14
     */
15
    public static $fakeTable;
16
17
    /**
18
     * @var
19
     */
20
    public static $fakePrimaryKey;
21
//
22
//	/**
23
//	 * @param array $attributes
24
//	 */
25
    public function __construct(array $attributes = array())
26
    {
27
        if (self::$fakeTable) {
28
            $this->table = self::$fakeTable;
29
        }
30
        if (self::$fakePrimaryKey) {
31
            $this->primaryKey = self::$fakePrimaryKey;
32
        }
33
34
        parent::__construct($attributes);
35
    }
36
37
    protected $guarded = array();
38
39
    public $timestamps = false;
40
41
    /**
42
     * @param $table
43
     * @param null $primaryKey
0 ignored issues
show
Bug introduced by
There is no parameter named $primaryKey. 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...
44
     * @return static
45
     */
46
    public function setup($config)
47
    {
48
        if (isset($config['table'])) {
49
            $this->table = $config['table'];
50
        } else {
51
            if (isset($config['model'])) {
52
                $this->table = str_plural(snake_case($config['model']));
53
            }
54
        }
55
56
        if (isset($config['primaryKey'])) {
57
            $this->primaryKey = $config['primaryKey'];
58
        }
59
60
        self::$fakeTable = $this->table;
61
        self::$fakePrimaryKey = $this->primaryKey;
62
63
        return $this;
64
    }
65
}