| 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 |
||
| 75 | public function testFileLog() |
||
| 76 | { |
||
| 77 | $root = vfsStream::setup(); |
||
| 78 | |||
| 79 | $this->config->shouldReceive('get')->with("log.default", null)->andReturn('file'); |
||
| 80 | |||
| 81 | $this->config->shouldReceive('get')->with("log.channels.file", null)->andReturn(['type' => 'file', 'path' => $root->url()]); |
||
| 82 | |||
| 83 | $this->log->info('foo'); |
||
| 84 | |||
| 85 | $this->assertEquals($this->log->getLog(), ['info' => ['foo']]); |
||
| 86 | |||
| 87 | $this->log->clear(); |
||
| 88 | |||
| 89 | $this->assertEmpty($this->log->getLog()); |
||
| 90 | |||
| 91 | $this->log->error('foo'); |
||
| 92 | $this->assertArrayHasKey('error', $this->log->getLog()); |
||
| 93 | |||
| 94 | $this->log->emergency('foo'); |
||
| 95 | $this->assertArrayHasKey('emergency', $this->log->getLog()); |
||
| 96 | |||
| 97 | $this->log->alert('foo'); |
||
| 98 | $this->assertArrayHasKey('alert', $this->log->getLog()); |
||
| 99 | |||
| 100 | $this->log->critical('foo'); |
||
| 101 | $this->assertArrayHasKey('critical', $this->log->getLog()); |
||
| 102 | |||
| 103 | $this->log->warning('foo'); |
||
| 104 | $this->assertArrayHasKey('warning', $this->log->getLog()); |
||
| 105 | |||
| 106 | $this->log->notice('foo'); |
||
| 107 | $this->assertArrayHasKey('notice', $this->log->getLog()); |
||
| 108 | |||
| 109 | $this->log->debug('foo'); |
||
| 110 | $this->assertArrayHasKey('debug', $this->log->getLog()); |
||
| 111 | |||
| 112 | $this->log->sql('foo'); |
||
| 113 | $this->assertArrayHasKey('sql', $this->log->getLog()); |
||
| 114 | |||
| 115 | $this->log->custom('foo'); |
||
| 116 | $this->assertArrayHasKey('custom', $this->log->getLog()); |
||
| 117 | |||
| 118 | $this->log->write('foo'); |
||
| 119 | $this->assertTrue($root->hasChildren()); |
||
| 120 | $this->assertEmpty($this->log->getLog()); |
||
| 121 | |||
| 122 | $this->log->close(); |
||
| 123 | |||
| 124 | $this->log->info('foo'); |
||
| 125 | |||
| 126 | $this->assertEmpty($this->log->getLog()); |
||
| 127 | } |
||
| 145 |