EloquentInputType::__sleep()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 8
rs 10
cc 1
nc 1
nop 0
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