FormModel::id()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
crap 1
1
<?php
2
3
namespace LaravelPlus\Extension\Specs;
4
5
class FormModel
6
{
7
    /**
8
     * @param string $id
9
     * @param string $path
10
     *
11
     * @return static
12
     */
13 1
    public static function make($id, $path)
14
    {
15 1
        return new static($id, new InputSpec(app('specs'), app('translator'), $path));
16
    }
17
18
    /**
19
     *	Form name for HTML Element.
20
     *
21
     *	@var string
22
     */
23
    protected $id;
24
25
    /**
26
     *	Form spec.
27
     *
28
     *	@var \LaravelPlus\Extension\Specs\InputSpec
29
     */
30
    protected $spec;
31
32
    /**
33
     * @param string $id
34
     * @param LaravelPlus\Extension\Specs\InputSpec $path
35
     */
36 2
    public function __construct($id, InputSpec $spec)
37
    {
38 2
        $this->id = $id;
39 2
        $this->spec = $spec;
40 2
    }
41
42
    /**
43
     * @return string
44
     */
45 1
    public function id()
46
    {
47 1
        return $this->id;
48
    }
49
50
    /**
51
     * @param $fieldName
52
     *
53
     * @return string
54
     */
55 1
    public function fieldId($fieldName)
56
    {
57 1
        return $this->id.'-'.$fieldName;
58
    }
59
60
    /**
61
     * @param string $method
62
     *
63
     * @return array $arguments
64
     * @return mixed
65
     */
66 1
    public function __call($method, $arguments)
67
    {
68 1
        return call_user_func_array([$this->spec, $method], $arguments);
69
    }
70
}
71