Int   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 9
Bugs 1 Features 1
Metric Value
wmc 3
c 9
b 1
f 1
lcom 1
cbo 3
dl 0
loc 38
ccs 7
cts 7
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getSigned() 0 4 1
A setSigned() 0 4 1
A read() 0 4 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
}