Skip to content

Commit 10e8875

Browse files
committed
fix for phpcs PSR12
1 parent 7af1b55 commit 10e8875

File tree

8 files changed

+44
-27
lines changed

8 files changed

+44
-27
lines changed

library/Odesk/Phystrix/AbstractCommand.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,11 @@ public function execute()
231231

232232
// trying from cache first
233233
if ($cacheEnabled) {
234-
$cacheHit = $this->requestCache->has($this->getCommandKey().'.'.$this->getCacheKey());
234+
$cacheHit = $this->requestCache->has($this->getCommandKey() . '.' . $this->getCacheKey());
235235
if ($cacheHit) {
236236
$metrics->markResponseFromCache();
237237
$this->recordExecutionEvent(self::EVENT_RESPONSE_FROM_CACHE);
238-
return $this->requestCache->get($this->getCommandKey().'.'.$this->getCacheKey());
238+
return $this->requestCache->get($this->getCommandKey() . '.' . $this->getCacheKey());
239239
}
240240
}
241241
$circuitBreaker = $this->getCircuitBreaker();
@@ -265,7 +265,7 @@ public function execute()
265265

266266
// putting the result into cache
267267
if ($cacheEnabled) {
268-
$this->requestCache->set($this->getCommandKey().'.'.$this->getCacheKey(), $result);
268+
$this->requestCache->set($this->getCommandKey() . '.' . $this->getCacheKey(), $result);
269269
}
270270

271271
return $result;

library/Odesk/Phystrix/ApcuStateStorage.php

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* This file is a part of the Phystrix library
45
*
@@ -16,20 +17,21 @@
1617
* See the License for the specific language governing permissions and
1718
* limitations under the License.
1819
*/
20+
1921
namespace Odesk\Phystrix;
2022

2123
/**
2224
* APCU cache driven storage for Circuit Breaker metrics statistics
2325
*/
2426
class ApcuStateStorage implements StateStorageInterface
2527
{
26-
const BUCKET_EXPIRE_SECONDS = 120;
28+
public const BUCKET_EXPIRE_SECONDS = 120;
2729

28-
const CACHE_PREFIX = 'phystrix_cb_';
30+
public const CACHE_PREFIX = 'phystrix_cb_';
2931

30-
const OPENED_NAME = 'opened';
32+
public const OPENED_NAME = 'opened';
3133

32-
const SINGLE_TEST_BLOCKED = 'single_test_blocked';
34+
public const SINGLE_TEST_BLOCKED = 'single_test_blocked';
3335

3436
/**
3537
* Constructor
@@ -129,7 +131,7 @@ public function allowSingleTest($commandKey, $sleepingWindowInMilliseconds)
129131
// using 'add' enforces thread safety.
130132
$sleepingWindowInSeconds = ceil($sleepingWindowInMilliseconds / 1000);
131133
// another APCU limitation is that within the current request variables will never expire.
132-
return (boolean) apcu_add($singleTestFlagKey, true, $sleepingWindowInSeconds);
134+
return (bool) apcu_add($singleTestFlagKey, true, $sleepingWindowInSeconds);
133135
}
134136

135137
/**
@@ -141,7 +143,7 @@ public function allowSingleTest($commandKey, $sleepingWindowInMilliseconds)
141143
public function isCircuitOpen($commandKey)
142144
{
143145
$openedKey = $this->prefix($commandKey . self::OPENED_NAME);
144-
return (boolean) apcu_fetch($openedKey);
146+
return (bool) apcu_fetch($openedKey);
145147
}
146148

147149
/**

library/Odesk/Phystrix/MetricsEventStream/ApcMetricsPoller.php

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* This file is a part of the phystrix-dashboard package
45
*
@@ -16,6 +17,7 @@
1617
* See the License for the specific language governing permissions and
1718
* limitations under the License.
1819
*/
20+
1921
namespace Odesk\Phystrix\MetricsEventStream;
2022

2123
use APCIterator;

library/Odesk/Phystrix/MetricsEventStream/ApcuMetricsPoller.php

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* This file is a part of the phystrix-dashboard package
45
*
@@ -16,6 +17,7 @@
1617
* See the License for the specific language governing permissions and
1718
* limitations under the License.
1819
*/
20+
1921
namespace Odesk\Phystrix\MetricsEventStream;
2022

2123
use APCUIterator;

library/Odesk/Phystrix/MetricsEventStream/MetricsPollerInterface.php

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* This file is a part of the phystrix-dashboard package
45
*
@@ -16,6 +17,7 @@
1617
* See the License for the specific language governing permissions and
1718
* limitations under the License.
1819
*/
20+
1921
namespace Odesk\Phystrix\MetricsEventStream;
2022

2123
/**

library/Odesk/Phystrix/MetricsEventStream/MetricsServer.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* This file is a part of the phystrix-dashboard package
45
*
@@ -16,14 +17,15 @@
1617
* See the License for the specific language governing permissions and
1718
* limitations under the License.
1819
*/
20+
1921
namespace Odesk\Phystrix\MetricsEventStream;
2022

2123
/**
2224
* Serves Phystrix metrics in text/event-stream format
2325
*/
2426
class MetricsServer
2527
{
26-
const DEFAULT_DELAY = 500; // in milliseconds
28+
public const DEFAULT_DELAY = 500; // in milliseconds
2729

2830
/**
2931
* @var integer

tests/Tests/Odesk/Phystrix/CommandTest.php

+12-5
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ public function testRequestLogOff()
200200
*
201201
* @param bool $logEnabled whether config is set to use request log
202202
* @throws Exception
203+
* @throws \Psr\SimpleCache\InvalidArgumentException
203204
*/
204205
public function testRequestLogNotInjected($logEnabled)
205206
{
@@ -227,6 +228,7 @@ public function testRequestLogNotInjected($logEnabled)
227228
*
228229
* @param bool $cacheEnabled whether config is set to use request log
229230
* @throws Exception
231+
* @throws \Psr\SimpleCache\InvalidArgumentException
230232
*/
231233
public function testRequestCacheNotInjected($cacheEnabled)
232234
{
@@ -261,6 +263,7 @@ public function configBoolProvider()
261263

262264
/**
263265
* @throws Exception
266+
* @throws \Psr\SimpleCache\InvalidArgumentException
264267
*/
265268
public function testExecuteRequestNotAllowed()
266269
{
@@ -286,6 +289,7 @@ public function testExecuteRequestNotAllowed()
286289

287290
/**
288291
* @throws Exception
292+
* @throws \Psr\SimpleCache\InvalidArgumentException
289293
*/
290294
public function testExecuteRunException()
291295
{
@@ -341,6 +345,7 @@ public function testExecuteFallbackFailed()
341345

342346
/**
343347
* @throws Exception
348+
* @throws \Psr\SimpleCache\InvalidArgumentException
344349
*/
345350
public function testRuntimeExceptionPopulated()
346351
{
@@ -362,6 +367,7 @@ public function testRuntimeExceptionPopulated()
362367

363368
/**
364369
* @throws Exception
370+
* @throws \Psr\SimpleCache\InvalidArgumentException
365371
*/
366372
public function testBadRequestExceptionTracksNoMetrics()
367373
{
@@ -386,6 +392,7 @@ public function testBadRequestExceptionTracksNoMetrics()
386392

387393
/**
388394
* @throws Exception
395+
* @throws \Psr\SimpleCache\InvalidArgumentException
389396
*/
390397
public function testShortCircuitedExceptionMessage()
391398
{
@@ -445,11 +452,11 @@ public function testRequestCacheHit()
445452
$requestCache = $this->createMock('Odesk\Phystrix\RequestCache');
446453
$requestCache->expects($this->once())
447454
->method('has')
448-
->with('Tests.Odesk.Phystrix.CommandMock'.'.'.'test-cache-key')
455+
->with('Tests.Odesk.Phystrix.CommandMock' . '.' . 'test-cache-key')
449456
->will($this->returnValue(true));
450457
$requestCache->expects($this->once())
451458
->method('get')
452-
->with('Tests.Odesk.Phystrix.CommandMock'.'.'.'test-cache-key')
459+
->with('Tests.Odesk.Phystrix.CommandMock' . '.' . 'test-cache-key')
453460
->will($this->returnValue('result from cache'));
454461
$this->command->cacheKey = 'test-cache-key';
455462
$this->command->setRequestCache($requestCache);
@@ -471,13 +478,13 @@ public function testRequestCacheMiss()
471478
$requestCache = $this->createMock('Odesk\Phystrix\RequestCache');
472479
$requestCache->expects($this->once())
473480
->method('has')
474-
->with('Tests.Odesk.Phystrix.CommandMock'.'.'.'test-cache-key')
481+
->with('Tests.Odesk.Phystrix.CommandMock' . '.' . 'test-cache-key')
475482
->will($this->returnValue(false));
476483
$requestCache->expects($this->never())
477484
->method('get');
478485
$requestCache->expects($this->once())
479486
->method('set')
480-
->with('Tests.Odesk.Phystrix.CommandMock'.'.'.'test-cache-key', 'run result');
487+
->with('Tests.Odesk.Phystrix.CommandMock' . '.' . 'test-cache-key', 'run result');
481488
$this->command->cacheKey = 'test-cache-key';
482489
$this->command->setRequestCache($requestCache);
483490
$this->commandMetrics->expects($this->never())->method('markResponseFromCache');
@@ -496,7 +503,7 @@ public function testSavesResultToCache()
496503
$requestCache = $this->createMock('Odesk\Phystrix\RequestCache');
497504
$requestCache->expects($this->once())
498505
->method('set')
499-
->with('Tests.Odesk.Phystrix.CommandMock'.'.'.'test-cache-key', 'run result');
506+
->with('Tests.Odesk.Phystrix.CommandMock' . '.' . 'test-cache-key', 'run result');
500507
$this->command->cacheKey = 'test-cache-key';
501508
$this->command->setRequestCache($requestCache);
502509
$this->assertEquals('run result', $this->command->execute());

tests/Tests/Odesk/Phystrix/RequestCacheTest.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -38,34 +38,34 @@ protected function setUp()
3838
public function testGetAndPut()
3939
{
4040
$result = (object) array('a' => 123);
41-
$this->assertNull($this->requestCache->get('TestCommand'.'cache-key-123'));
42-
$this->requestCache->set('TestCommand'.'cache-key-123', $result);
43-
$this->assertEquals($result, $this->requestCache->get('TestCommand'.'cache-key-123'));
41+
$this->assertNull($this->requestCache->get('TestCommand' . 'cache-key-123'));
42+
$this->requestCache->set('TestCommand' . 'cache-key-123', $result);
43+
$this->assertEquals($result, $this->requestCache->get('TestCommand' . 'cache-key-123'));
4444
}
4545

4646
public function testClear()
4747
{
4848
$result = (object) array('a' => 123);
49-
$this->requestCache->set('TestCommand'.'cache-key-123', $result);
50-
$this->assertEquals($result, $this->requestCache->get('TestCommand'.'cache-key-123'));
49+
$this->requestCache->set('TestCommand' . 'cache-key-123', $result);
50+
$this->assertEquals($result, $this->requestCache->get('TestCommand' . 'cache-key-123'));
5151
$this->requestCache->clear();
52-
$this->assertNull($this->requestCache->get('TestCommand'.'cache-key-123'));
52+
$this->assertNull($this->requestCache->get('TestCommand' . 'cache-key-123'));
5353
}
5454

5555
public function testClearAll()
5656
{
5757
$result = (object) array('a' => 123);
58-
$this->requestCache->set('TestCommand'.'cache-key-123', $result);
59-
$this->assertEquals($result, $this->requestCache->get('TestCommand'.'cache-key-123'));
58+
$this->requestCache->set('TestCommand' . 'cache-key-123', $result);
59+
$this->assertEquals($result, $this->requestCache->get('TestCommand' . 'cache-key-123'));
6060
$this->requestCache->clear();
61-
$this->assertNull($this->requestCache->get('TestCommand'.'cache-key-123'));
61+
$this->assertNull($this->requestCache->get('TestCommand' . 'cache-key-123'));
6262
}
6363

6464
public function testExists()
6565
{
6666
$result = (object) array('a' => 123);
67-
$this->assertFalse($this->requestCache->has('TestCommand'.'cache-key-123'));
68-
$this->requestCache->set('TestCommand'.'cache-key-123', $result);
69-
$this->assertTrue($this->requestCache->has('TestCommand'.'cache-key-123'));
67+
$this->assertFalse($this->requestCache->has('TestCommand' . 'cache-key-123'));
68+
$this->requestCache->set('TestCommand' . 'cache-key-123', $result);
69+
$this->assertTrue($this->requestCache->has('TestCommand' . 'cache-key-123'));
7070
}
7171
}

0 commit comments

Comments
 (0)