Completed
Push — develop ( 90d434...5a25e9 )
by Michael
02:38
created

Partial::jsonSerialize()   A

Complexity

Conditions 3
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 9.4285
cc 3
eloc 5
nc 1
nop 0
crap 3
1
<?php
2
3
namespace Crummy\Phlack\Message;
4
5
use Crummy\Phlack\Common\Hash;
6
7
abstract class Partial extends Hash
8
{
9
    /**
10
     * @return array
11
     */
12
    public function jsonSerialize()
13
    {
14 6
        return array_filter($this->toArray(), function ($value) {
15 6
            if ($value instanceof \Countable) {
16 5
                return 0 < $value->count();
17
            }
18
19 6
            return false === $value || !empty($value);
20 6
        });
21
    }
22
}
23