Completed
Push — master ( 6391fe...b20865 )
by Akihito
02:23
created

Formatter::serialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 8
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
namespace Ackintosh\Snidel\Result;
3
4
use Ackintosh\Snidel\Result\Result;
5
use Ackintosh\Snidel\Fork;
6
7
class Formatter
8
{
9 View Code Duplication
    public static function serialize(Result $result)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
    {
11
        $cloned = clone $result;
12
        $serializedFork = Fork::serialize($cloned->getFork());
13
        $cloned->setFork(null);
14
15
        return serialize(array('serializedFork' => $serializedFork, 'result' => $cloned));
16
    }
17
18 View Code Duplication
    public static function minifyAndSerialize(Result $result)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
    {
20
        $cloned = clone $result;
21
        $serializedFork = Fork::minifyAndSerialize($cloned->getFork());
22
        $cloned->setFork(null);
23
24
        return serialize(array('serializedFork' => $serializedFork, 'result' => $cloned));
25
    }
26
27
    public static function unserialize($serializedResult)
28
    {
29
        $unserialized = unserialize($serializedResult);
30
        $unserialized['result']->setFork(Fork::unserialize($unserialized['serializedFork']));
31
32
        return $unserialized['result'];
33
    }
34
}
35