Int::getSigned()   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 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Zerg\Field;
4
5
use Zerg\Stream\AbstractStream;
6
7
/**
8
 * Int field read data from Stream and cast it to integer.
9
 *
10
 * @since 0.1
11
 * @package Zerg\Field
12
 */
13
class Int extends Scalar
14
{
15
    /**
16
     * @var bool Whether field is signed. If so, value form stream will be casted to signed integer.
17
     */
18
    protected $signed;
19
20
    /**
21
     * Getter for signed property.
22
     *
23
     * @return bool
24
     */
25 20
    public function getSigned()
26
    {
27 20
        return (bool) $this->signed;
28
    }
29
30
    /**
31
     * Setter for signed property.
32
     *
33
     * @param bool $signed
34
     */
35 8
    public function setSigned($signed)
36
    {
37 8
        $this->signed = $signed;
38 8
    }
39
40
    /**
41
     * Read data from Stream and cast it to integer.
42
     *
43
     * @param AbstractStream $stream Stream from which read.
44
     * @return int Result value.
0 ignored issues
show
Documentation introduced by
Should the return type not be integer|string?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
45
     */
46 18
    public function read(AbstractStream $stream)
47
    {
48 18
        return $stream->getBuffer()->readInt($this->getSize(), $this->getSigned(), $this->getEndian());
49
    }
50
}