UnsignedCharField::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Wowstack\Dbc\MappingField;
6
7
/**
8
 * Implements a field containing unsigned char values.
9
 */
10
class UnsignedCharField extends AbstractField implements MappingFieldInterface
11
{
12
    /**
13
     * Name of type.
14
     */
15
    const TYPE = 'uchar';
16
17
    /**
18
     * {@inheritdoc}
19
     */
20
    protected $size = 1;
21
22
    /**
23
     * Amount of fields to follow.
24
     *
25
     * @var int
26
     */
27
    protected $count = 0;
28
29
    /**
30
     * Defines required parameters.
31
     */
32
    const PARAMETERS = ['count'];
33
34
    /**
35
     * Defines optional parameters and their defaults.
36
     */
37
    const OPTIONAL_PARAMETERS = [];
38
39
    /**
40
     * Format used to pack/unpack this field type.
41
     */
42
    const PACK_FORMAT = 'C';
43
44
    /**
45
     * Constructs the field.
46
     *
47
     * @param string $name
48
     * @param array  $parameters
49
     *
50
     * @throws MappingException
51
     */
52 5
    public function __construct(string $name, array $parameters = [])
53
    {
54 5
        $this->name = $name;
55 5
        $this->setParameters($parameters);
56 4
        $this->setOptionalParameters($parameters);
57 4
    }
58
}
59