EloquentInputType   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 10
c 1
b 0
f 0
dl 0
loc 41
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __sleep() 0 8 1
A __construct() 0 6 1
1
<?php
2
3
namespace Bakery\Types\Definitions;
4
5
use Bakery\Eloquent\ModelSchema;
6
use Bakery\Support\TypeRegistry;
7
8
class EloquentInputType extends InputType
9
{
10
    /**
11
     * The underlying model schema.
12
     *
13
     * @var \Bakery\Eloquent\ModelSchema
14
     */
15
    protected $modelSchema;
16
17
    /**
18
     * @var \Illuminate\Database\Eloquent\Model
19
     */
20
    protected $model;
21
22
    /**
23
     * Construct a new Eloquent type.
24
     *
25
     * @param \Bakery\Support\TypeRegistry $registry
26
     * @param \Bakery\Eloquent\ModelSchema $modelSchema
27
     */
28
    public function __construct(TypeRegistry $registry, ModelSchema $modelSchema)
29
    {
30
        parent::__construct($registry);
31
32
        $this->modelSchema = $modelSchema;
33
        $this->model = $modelSchema->getModel();
34
    }
35
36
    /**
37
     * Define the fields that should be serialized.
38
     *
39
     * @return array
40
     */
41
    public function __sleep()
42
    {
43
        $fields = [
44
            'modelSchema',
45
            'model',
46
        ];
47
48
        return array_merge($fields, parent::__sleep());
49
    }
50
}
51