AbstractClient   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A correctEndianness() 0 4 2
A __construct() 0 7 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