Conditions | 1 |
Paths | 1 |
Total Lines | 54 |
Code Lines | 41 |
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 |
||
71 | public function testSettingProperties() |
||
72 | { |
||
73 | $definition = new JsonFormat(); |
||
74 | |||
75 | static::assertEquals( |
||
76 | JsonFormat::JSON_FILE_TYPE_SINGLE_BLOCK, |
||
77 | $definition->getJsonFileType(), |
||
78 | "File Type should be single block" |
||
79 | ); |
||
80 | static::assertEquals(0, $definition->getJsonEncodeOptions(), "Default encode options should be 0"); |
||
81 | static::assertEquals(0, $definition->getJsonDecodeOptions(), "Default decode options should be 0"); |
||
82 | static::assertFalse($definition->isJsonDecodeAssoc(), "Default decode association should be false"); |
||
83 | static::assertTrue($definition->isIgnoreBlankLines(), "Default ignore blank lines should be true"); |
||
84 | |||
85 | static::assertSame( |
||
86 | $definition, |
||
87 | $definition->setJsonFileType(JsonFormat::JSON_FILE_TYPE_EACH_LINE), |
||
88 | "setJsonFileType should be fluent" |
||
89 | ); |
||
90 | static::assertEquals( |
||
91 | JsonFormat::JSON_FILE_TYPE_EACH_LINE, |
||
92 | $definition->getJsonFileType(), |
||
93 | "File Type should be set to: Each Line" |
||
94 | ); |
||
95 | static::assertSame( |
||
96 | $definition, |
||
97 | $definition->setJsonEncodeOptions(JSON_HEX_APOS | JSON_FORCE_OBJECT), |
||
98 | "setJsonEncodeOptions should be fluent" |
||
99 | ); |
||
100 | static::assertEquals( |
||
101 | JSON_HEX_APOS | JSON_FORCE_OBJECT, |
||
102 | $definition->getJsonEncodeOptions(), |
||
103 | "Encode options should be: HEX_APOS and FORCE_OBJECT" |
||
104 | ); |
||
105 | static::assertSame( |
||
106 | $definition, |
||
107 | $definition->setJsonDecodeOptions(JSON_BIGINT_AS_STRING), |
||
108 | "setJsonDencodeOptions should be fluent" |
||
109 | ); |
||
110 | static::assertEquals( |
||
111 | JSON_BIGINT_AS_STRING, |
||
112 | $definition->getJsonDecodeOptions(), |
||
113 | "Decode options should be BIGINT_AS_STRING" |
||
114 | ); |
||
115 | |||
116 | static::assertSame($definition, $definition->setJsonDecodeAssoc(true), "setJsonDecodeAssoc should be fluent"); |
||
117 | static::assertTrue($definition->isJsonDecodeAssoc(), "JsonDecodeAssoc should be true"); |
||
118 | static::assertSame( |
||
119 | $definition, |
||
120 | $definition->setIgnoreBlankLines(false), |
||
121 | "setIgnoreBlankLines should be fluent" |
||
122 | ); |
||
123 | static::assertFalse($definition->isIgnoreBlankLines(), "Ignore Blank Lines should be false"); |
||
124 | } |
||
125 | } |
||
126 |