AMQPTable   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 31
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getType() 0 3 1
A set() 0 15 3
1
<?php
2
3
namespace PhpAmqpLib\Wire;
4
5
use PhpAmqpLib\Exception;
6
7
class AMQPTable extends AMQPAbstractCollection
8
{
9
10
    /**
11
     * @return int
12
     */
13 3
    final public function getType()
14
    {
15 3
        return self::T_TABLE;
16
    }
17
18
    /**
19
     * @param string $key
20
     * @param mixed $val
21
     * @param int|null $type
22
     */
23 13
    public function set($key, $val, $type = null)
24
    {
25
        //https://www.rabbitmq.com/resources/specs/amqp0-9-1.pdf, https://www.rabbitmq.com/resources/specs/amqp0-8.pdf
26
        //Field names MUST start with a letter, '$' or '#' and may continue with letters, '$' or '#', digits,
27
        // or underlines, to a maximum length of 128 characters
28
        //The server SHOULD validate field names and upon receiving an invalid field name, it SHOULD signal a connection
29
        // exception with reply code 503 (syntax error)
30
31
        //validating length only and delegating other stuff to server, as rabbit seems to currently support numeric keys
32 13
        if (!($len = strlen($key)) || ($len > 128)) {
33 2
            throw new Exception\AMQPInvalidArgumentException(
34
                'Table key must be non-empty string up to 128 chars in length'
35
            );
36
        }
37 11
        $this->setValue($val, $type, $key);
38
    }
39
}
40