Conditions | 1 |
Paths | 1 |
Total Lines | 52 |
Code Lines | 31 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
61 | public function testFileLog() |
||
62 | { |
||
63 | $root = vfsStream::setup(); |
||
64 | |||
65 | $this->config->shouldReceive('get')->with("log.default", null)->andReturn('file'); |
||
66 | |||
67 | $this->config->shouldReceive('get')->with("log.channels.file", null)->andReturn(['type' => 'file', 'path' => $root->url()]); |
||
68 | |||
69 | $this->log->info('foo'); |
||
70 | |||
71 | $this->assertEquals($this->log->getLog(), ['info' => ['foo']]); |
||
72 | |||
73 | $this->log->clear(); |
||
74 | |||
75 | $this->assertEmpty($this->log->getLog()); |
||
76 | |||
77 | $this->log->error('foo'); |
||
78 | $this->assertArrayHasKey('error', $this->log->getLog()); |
||
79 | |||
80 | $this->log->emergency('foo'); |
||
81 | $this->assertArrayHasKey('emergency', $this->log->getLog()); |
||
82 | |||
83 | $this->log->alert('foo'); |
||
84 | $this->assertArrayHasKey('alert', $this->log->getLog()); |
||
85 | |||
86 | $this->log->critical('foo'); |
||
87 | $this->assertArrayHasKey('critical', $this->log->getLog()); |
||
88 | |||
89 | $this->log->warning('foo'); |
||
90 | $this->assertArrayHasKey('warning', $this->log->getLog()); |
||
91 | |||
92 | $this->log->notice('foo'); |
||
93 | $this->assertArrayHasKey('notice', $this->log->getLog()); |
||
94 | |||
95 | $this->log->debug('foo'); |
||
96 | $this->assertArrayHasKey('debug', $this->log->getLog()); |
||
97 | |||
98 | $this->log->sql('foo'); |
||
99 | $this->assertArrayHasKey('sql', $this->log->getLog()); |
||
100 | |||
101 | $this->log->custom('foo'); |
||
102 | $this->assertArrayHasKey('custom', $this->log->getLog()); |
||
103 | |||
104 | $this->log->write('foo'); |
||
105 | $this->assertTrue($root->hasChildren()); |
||
106 | $this->assertEmpty($this->log->getLog()); |
||
107 | |||
108 | $this->log->close(); |
||
109 | |||
110 | $this->log->info('foo'); |
||
111 | |||
112 | $this->assertEmpty($this->log->getLog()); |
||
113 | } |
||
131 |