Completed
Push — master ( 42b611...b70ab3 )
by light
02:44
created

Image::validateSelf()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4.0218

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 12
ccs 8
cts 9
cp 0.8889
rs 9.2
cc 4
eloc 7
nc 4
nop 0
crap 4.0218
1
<?php
2
3
namespace light\Easemob\Message;
4
5
use light\Easemob\Exception\InvalidArgumentException;
6
7
class Image extends Message
8
{
9
    /**
10
     * Message type.
11
     *
12
     * @var string
13
     */
14
    protected $type = self::TYPE_IMG;
15
16
    protected $properties = ['url', 'filename', 'secret', 'size'];
17
18
    /**
19
     * @inheritdoc
20
     */
21 2
    protected function validateSelf()
22
    {
23 2
        parent::validateSelf();
24 2
        foreach($this->properties as $prop) {
25 2
            if ('size' == $prop) {
26 2
                continue;
27
            }
28 2
            if (empty($this->{$prop})) {
29
                throw new InvalidArgumentException("{$prop} can not be null");
30
            }
31 2
        }
32 2
    }
33
34
}
35