Bin::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Fhp\DataTypes;
4
5
/**
6
 * Class Bin
7
 * @package Fhp\DataTypes
8
 */
9
class Bin
10
{
11
    /**
12
     * @var string
13
     */
14
    protected $string;
15
16
    /**
17
     * Bin constructor.
18
     *
19
     * @param string $string
20
     */
21 5
    public function __construct($string)
22
    {
23 5
        $this->string = $string;
24 5
    }
25
26
    /**
27
     * Sets the binary data.
28
     *
29
     * @param string $data
30
     * @return $this
31
     */
32 1
    public function setData($data)
33
    {
34 1
        $this->string = $data;
35
36 1
        return $this;
37
    }
38
39
    /**
40
     * Gets the binary data.
41
     *
42
     * @return string
43
     */
44 5
    public function getData()
45
    {
46 5
        return $this->string;
47
    }
48
49
    /**
50
     * Convert to string.
51
     *
52
     * @return string
53
     */
54 3
    public function toString()
55
    {
56 3
        return '@' . strlen($this->string) . '@' . $this->string;
57
    }
58
59
    /**
60
     * @return string
61
     */
62 3
    public function __toString()
63
    {
64 3
        return $this->toString();
65
    }
66
}
67