FieldFactory::newFieldCollection()   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
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * Jnjxp\Form
4
 *
5
 * PHP version 5
6
 *
7
 * Copyright (C) 2016 Jake Johns
8
 *
9
 * This software may be modified and distributed under the terms
10
 * of the MIT license.  See the LICENSE file for details.
11
 *
12
 * @category  Factory
13
 * @package   Jnjxp\Form
14
 * @author    Jake Johns <[email protected]>
15
 * @copyright 2016 Jake Johns
16
 * @license   http://jnj.mit-license.org/2016 MIT License
17
 * @link      http://github.com/jnjxp/jnjxp.form
18
 */
19
20
namespace Jnjxp\Form;
21
22
/**
23
 * Factory
24
 *
25
 * @category Factory
26
 * @package  Jnjxp\Form
27
 * @author   Jake Johns <[email protected]>
28
 * @license  http://jnj.mit-license.org/ MIT License
29
 * @link     http://github.com/jnjxp/jnjxp.form
30
 */
31
class FieldFactory
32
{
33
34
    /**
35
     * Create a new field
36
     *
37
     * @param string $name  name of field
38
     * @param string $class Field class
39
     *
40
     * @return Field
41
     *
42
     * @access public
43
     */
44 7
    public function newField($name, $class = Field::class)
45
    {
46 7
        return new $class($name);
47
    }
48
49
    /**
50
     * Create a new FieldCollection
51
     *
52
     * @param string $class FieldCollection class
53
     *
54
     * @return FieldCollection
55
     *
56
     * @access public
57
     */
58 1
    public function newFieldCollection($class = FieldCollection::class)
59
    {
60 1
        return new $class($this);
61
    }
62
}
63