Conditions | 1 |
Paths | 1 |
Total Lines | 52 |
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 namespace GeneaLabs\LaravelModelCaching\Tests\Integration\Console\Commands; |
||
111 | public function testAllModelsAreFlushed() |
||
112 | { |
||
113 | (new Author)->all(); |
||
114 | (new Book)->all(); |
||
115 | (new Store)->all(); |
||
116 | |||
117 | $key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthor-authors.deleted_at_null"); |
||
118 | $tags = ["genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthor"]; |
||
119 | $cachedAuthors = $this->cache |
||
120 | ->tags($tags) |
||
121 | ->get($key)['value']; |
||
122 | $key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:books:genealabslaravelmodelcachingtestsfixturesbook"); |
||
123 | $tags = ["genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesbook"]; |
||
124 | $cachedBooks = $this->cache |
||
125 | ->tags($tags) |
||
126 | ->get($key)['value']; |
||
127 | $key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:stores:genealabslaravelmodelcachingtestsfixturesstore"); |
||
128 | $tags = ["genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesstore"]; |
||
129 | $cachedStores = $this->cache |
||
130 | ->tags($tags) |
||
131 | ->get($key)['value']; |
||
132 | |||
133 | $this->assertNotEmpty($cachedAuthors); |
||
134 | $this->assertNotEmpty($cachedBooks); |
||
135 | $this->assertNotEmpty($cachedStores); |
||
136 | |||
137 | $this->artisan('modelCache:clear') |
||
138 | ->execute(); |
||
139 | |||
140 | $key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthor"); |
||
141 | $tags = ["genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthor"]; |
||
142 | $cachedAuthors = $this->cache |
||
143 | ->tags($tags) |
||
144 | ->get($key)['value'] |
||
145 | ?? null; |
||
146 | $key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:books:genealabslaravelmodelcachingtestsfixturesbook"); |
||
147 | $tags = ["genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesbook"]; |
||
148 | $cachedBooks = $this->cache |
||
149 | ->tags($tags) |
||
150 | ->get($key)['value'] |
||
151 | ?? null; |
||
152 | $key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:stores:genealabslaravelmodelcachingtestsfixturesstore"); |
||
153 | $tags = ["genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesstore"]; |
||
154 | $cachedStores = $this->cache |
||
155 | ->tags($tags) |
||
156 | ->get($key)['value'] |
||
157 | ?? null; |
||
158 | |||
159 | $this->assertEmpty($cachedAuthors); |
||
160 | $this->assertEmpty($cachedBooks); |
||
161 | $this->assertEmpty($cachedStores); |
||
162 | } |
||
163 | } |
||
164 |