Php::serialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
/**
4
 *
5
 * This file is part of the Apix Project.
6
 *
7
 * (c) Franck Cassedanne <franck at ouarz.net>
8
 *
9
 * @license     http://opensource.org/licenses/BSD-3-Clause  New BSD License
10
 *
11
 */
12
13
namespace Apix\Output;
14
15
class Php extends AbstractOutput
16
{
17
    public $debug = false;
18
19
    /**
20
     * {@inheritdoc}
21
     * @see http://www.ietf.org/rfc/rfc2046.txt
22
     * @see http://www.ietf.org/rfc/rfc3676.txt
23
      */
24
    protected $content_type = 'text/plain';
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function encode(array $data, $rootNode=null)
30
    {
31
        if (null !== $rootNode) {
32
            $data = array($rootNode => $data);
33
        }
34
35
        return false === $this->debug
36
                ? $this->serialize($data)
37
                : $this->dump($data);
38
    }
39
40
    public function serialize($data)
41
    {
42
        return serialize($data);
43
    }
44
45
    public function dump($data)
46
    {
47
        return print_r($data, true);
48
    }
49
50
}
51