| Conditions | 1 |
| Paths | 1 |
| Total Lines | 106 |
| Code Lines | 75 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 17 | public function testBasicDumps() |
||
| 18 | { |
||
| 19 | $testdata = array( |
||
| 20 | 1234, |
||
| 21 | (object) array('abc' => 'def'), |
||
| 22 | 1234.5678, |
||
| 23 | 'Good news everyone! I\'ve got some bad news!', |
||
| 24 | null, |
||
| 25 | ); |
||
| 26 | |||
| 27 | $testdata[] = &$testdata; |
||
| 28 | |||
| 29 | $array_structure = array( |
||
| 30 | '0', 'integer', '1234', |
||
| 31 | '1', 'stdClass', '1', |
||
| 32 | 'public', 'abc', 'string', '3', 'def', |
||
| 33 | '2', 'double', '1234.5678', |
||
| 34 | '3', 'string', '43', 'Good news everyone! I\'ve got some bad news!', |
||
| 35 | '4', 'null', |
||
| 36 | ); |
||
| 37 | |||
| 38 | Kint::$return = true; |
||
| 39 | Kint::$cli_detection = false; |
||
| 40 | Kint::$display_called_from = false; |
||
| 41 | |||
| 42 | Kint::$enabled_mode = Kint::MODE_RICH; |
||
| 43 | $richbase = d($testdata); |
||
| 44 | |||
| 45 | $this->assertLike( |
||
| 46 | array_merge( |
||
| 47 | $array_structure, |
||
| 48 | array('&array', '6'), |
||
| 49 | $array_structure, |
||
| 50 | array('&array', 'Recursion') |
||
| 51 | ), |
||
| 52 | $richbase |
||
| 53 | ); |
||
| 54 | |||
| 55 | Kint::$enabled_mode = true; |
||
| 56 | $this->assertSame($richbase, d($testdata)); |
||
| 57 | $this->assertSame($richbase, Kint::dump($testdata)); |
||
| 58 | |||
| 59 | Kint::$enabled_mode = Kint::MODE_PLAIN; |
||
| 60 | $plainbase = d($testdata); |
||
| 61 | |||
| 62 | $this->assertLike( |
||
| 63 | array_merge( |
||
| 64 | $array_structure, |
||
| 65 | array('&array', '6'), |
||
| 66 | $array_structure, |
||
| 67 | array('&array', 'RECURSION') |
||
| 68 | ), |
||
| 69 | $plainbase |
||
| 70 | ); |
||
| 71 | |||
| 72 | $this->assertSame($plainbase, Kint::dump($testdata)); |
||
| 73 | |||
| 74 | Kint::$enabled_mode = true; |
||
| 75 | $this->assertSame($plainbase, s($testdata)); |
||
| 76 | |||
| 77 | Kint::$enabled_mode = Kint::MODE_CLI; |
||
| 78 | $clibase = d($testdata); |
||
| 79 | |||
| 80 | $this->assertLike( |
||
| 81 | array_merge( |
||
| 82 | $array_structure, |
||
| 83 | array('&array', '6'), |
||
| 84 | $array_structure, |
||
| 85 | array('&array', 'RECURSION') |
||
| 86 | ), |
||
| 87 | $clibase |
||
| 88 | ); |
||
| 89 | |||
| 90 | $this->assertSame($clibase, Kint::dump($testdata)); |
||
| 91 | |||
| 92 | Kint::$enabled_mode = true; |
||
| 93 | Kint::$cli_detection = true; |
||
| 94 | $this->assertSame($clibase, d($testdata)); |
||
| 95 | $this->assertSame($clibase, s($testdata)); |
||
| 96 | Kint::$cli_detection = false; |
||
| 97 | |||
| 98 | Kint::$enabled_mode = Kint::MODE_TEXT; |
||
| 99 | $textbase = d($testdata); |
||
| 100 | |||
| 101 | $this->assertLike( |
||
| 102 | array_merge( |
||
| 103 | $array_structure, |
||
| 104 | array('&array', '6'), |
||
| 105 | $array_structure, |
||
| 106 | array('&array', 'RECURSION') |
||
| 107 | ), |
||
| 108 | $textbase |
||
| 109 | ); |
||
| 110 | |||
| 111 | $this->assertSame($textbase, Kint::dump($testdata)); |
||
| 112 | |||
| 113 | Kint::$return = false; |
||
| 114 | Kint::$enabled_mode = true; |
||
| 115 | ob_start(); |
||
| 116 | ~d($testdata); |
||
| 117 | $this->assertSame($textbase, ob_get_clean()); |
||
| 118 | |||
| 119 | Kint::$enabled_mode = false; |
||
| 120 | $this->assertSame(0, d($testdata)); |
||
| 121 | $this->assertSame(0, s($testdata)); |
||
| 122 | } |
||
| 123 | |||
| 184 |