Completed
Pull Request — develop (#28)
by Michael
02:15
created

EncodableCollection::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Crummy\Phlack\Message\Collection;
4
5
use Crummy\Phlack\Common\Collection\TypeCollection;
6
use Crummy\Phlack\Common\Encodable;
7
8
abstract class EncodableCollection extends TypeCollection implements Encodable
9
{
10
    /**
11
     * @return string
12
     */
13 1
    public function __toString()
14
    {
15 1
        return json_encode($this);
16
    }
17
18
    /**
19
     * @return array|mixed
20
     */
21 2
    public function jsonSerialize()
22
    {
23 2
        return array_filter($this->toArray());
24
    }
25
}
26