Passed
Pull Request — master (#42)
by Viacheslav
02:53 queued 10s
created

DiffBench::init()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 36
Code Lines 61

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 61
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 36
rs 8.8509
1
<?php
2
3
use Swaggest\JsonDiff\JsonDiff;
4
5
class DiffBench
6
{
7
    static $simpleOriginal;
8
    static $simpleNew;
9
10
    static $original;
11
    static $new;
12
13
    public function benchSimpleSkipPatch()
14
    {
15
        new JsonDiff(self::$simpleOriginal, self::$simpleNew, JsonDiff::REARRANGE_ARRAYS);
16
    }
17
18
    public function benchSimpleRearrange()
19
    {
20
        new JsonDiff(self::$simpleOriginal, self::$simpleNew, JsonDiff::REARRANGE_ARRAYS);
21
    }
22
23
    public function benchSkipPatch()
24
    {
25
        new JsonDiff(self::$original, self::$new, JsonDiff::REARRANGE_ARRAYS);
26
    }
27
28
    public function benchRearrange()
29
    {
30
        new JsonDiff(self::$original, self::$new, JsonDiff::REARRANGE_ARRAYS);
31
    }
32
33
    public function benchStopOnDiff()
34
    {
35
        new JsonDiff(self::$original, self::$new, JsonDiff::STOP_ON_DIFF);
36
    }
37
38
39
    static function init()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
40
    {
41
        self::$simpleOriginal = (object)(array("root" => (object)array("a" => 1, "b" => 2)));
42
        self::$simpleNew = (object)(array("root" => (object)array("b" => 3, "c" => 4)));
43
        self::$original = json_decode(<<<'JSON'
44
{
45
  "key1": [
46
    4,
47
    1,
48
    2,
49
    3
50
  ],
51
  "key2": 2,
52
  "key3": {
53
    "sub0": 0,
54
    "sub1": "a",
55
    "sub2": "b"
56
  },
57
  "key4": [
58
    {
59
      "a": 1,
60
      "b": true
61
    },
62
    {
63
      "a": 2,
64
      "b": false
65
    },
66
    {
67
      "a": 3
68
    }
69
  ]
70
}
71
JSON
72
        );
73
74
        self::$new = json_decode(<<<'JSON'
75
{
76
  "key5": "wat",
77
  "key1": [
78
    5,
79
    1,
80
    2,
81
    3
82
  ],
83
  "key4": [
84
    {
85
      "c": false,
86
      "a": 2
87
    },
88
    {
89
      "a": 1,
90
      "b": true
91
    },
92
    {
93
      "c": 1,
94
      "a": 3
95
    }
96
  ],
97
  "key3": {
98
    "sub3": 0,
99
    "sub2": false,
100
    "sub1": "c"
101
  }
102
}
103
JSON
104
        );
105
    }
106
107
}
108
109
DiffBench::init();