AbstractClient::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
crap 1
1
<?php
2
namespace PhpAmqpLib\Wire;
3
4
5
class AbstractClient
6
{
7
8
    /**
9
     * @var bool
10
     */
11
    protected $is64bits;
12
13
    /**
14
     * @var bool
15
     */
16
    protected $isLittleEndian;
17
18 435
    public function __construct()
19
    {
20 435
        $this->is64bits = PHP_INT_SIZE == 8;
21
22 435
        $tmp = unpack('S', "\x01\x00"); // to maintain 5.3 compatibility
23 435
        $this->isLittleEndian = $tmp[1] == 1;
24 435
    }
25
26
    /**
27
     * Converts byte-string between native and network byte order, in both directions
28
     *
29
     * @param string $byteStr
30
     * @return string
31
     */
32 65
    protected function correctEndianness($byteStr)
33
    {
34 65
        return $this->isLittleEndian ? strrev($byteStr) : $byteStr;
35
    }
36
}
37