Skip to content

Commit 5f7fb0e

Browse files
author
Adam Grabek
committed
cs fixer fixes
1 parent a85d4bf commit 5f7fb0e

27 files changed

+224
-194
lines changed

Module.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
45
* @copyright Copyright (c) 2014 Zend Technologies USA Inc. (http://www.zend.com)
@@ -17,40 +18,40 @@
1718
use ZF\ApiProblem\View\ApiProblemStrategy;
1819

1920
/**
20-
* ZF2 module
21+
* ZF2 module.
2122
*/
2223
class Module
2324
{
2425
/**
25-
* Retrieve autoloader configuration
26+
* Retrieve autoloader configuration.
2627
*
2728
* @return array
2829
*/
2930
public function getAutoloaderConfig()
3031
{
3132
return [
3233
'Zend\Loader\StandardAutoloader' => ['namespaces' => [
33-
__NAMESPACE__ => __DIR__ . '/src/',
34+
__NAMESPACE__ => __DIR__.'/src/',
3435
]],
3536
];
3637
}
3738

3839
/**
39-
* Retrieve module configuration
40+
* Retrieve module configuration.
4041
*
4142
* @return array
4243
*/
4344
public function getConfig()
4445
{
45-
return include __DIR__ . '/config/module.config.php';
46+
return include __DIR__.'/config/module.config.php';
4647
}
4748

4849
/**
49-
* Listener for bootstrap event
50+
* Listener for bootstrap event.
5051
*
5152
* Attaches a render event.
5253
*
53-
* @param \Zend\Mvc\MvcEvent $e
54+
* @param \Zend\Mvc\MvcEvent $e
5455
*/
5556
public function onBootstrap($e)
5657
{
@@ -65,7 +66,6 @@ public function onBootstrap($e)
6566
/** @var SendResponseListener $sendResponseListener */
6667
$sendResponseListener = $serviceManager->get('SendResponseListener');
6768

68-
6969
$apiProblemListener->attach($eventManager);
7070
$eventManager->attach(MvcEvent::EVENT_RENDER, [$this, 'onRender'], 100);
7171

@@ -77,11 +77,11 @@ public function onBootstrap($e)
7777
}
7878

7979
/**
80-
* Listener for the render event
80+
* Listener for the render event.
8181
*
8282
* Attaches a rendering/response strategy to the View.
8383
*
84-
* @param \Zend\Mvc\MvcEvent $e
84+
* @param \Zend\Mvc\MvcEvent $e
8585
*/
8686
public function onRender($e)
8787
{

ModuleTest.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
2+
23
/**
34
* Creator: adamgrabek
45
* Date: 08.06.2016
5-
* Time: 00:06
6+
* Time: 00:06.
67
*/
78

89
namespace ZF\ApiProblem;
@@ -17,31 +18,26 @@
1718
use ZF\ApiProblem\Listener\ApiProblemListener;
1819
use ZF\ApiProblem\Listener\SendApiProblemResponseListener;
1920

20-
2121
class ModuleTest extends TestCase
2222
{
23-
2423
public function testOnBootstrap()
2524
{
2625
$module = new Module();
2726

28-
29-
$application = $this->getMock(Application::class, [], [], '', FALSE);
27+
$application = $this->getMock(Application::class, [], [], '', false);
3028
$serviceLocator = $this->getMockForAbstractClass(ServiceLocatorInterface::class);
3129
$serviceLocator->method('get')->will($this->returnCallback([$this, 'serviceLocator']));
3230

3331
$eventManager = new EventManager(new SharedEventManager());
3432
$event = $this->getMock(MvcEvent::class);
3533

36-
3734
$application->method('getServiceManager')->willReturn($serviceLocator);
3835
$application->method('getEventManager')->willReturn($eventManager);
3936
$event->expects($this->once())->method('getTarget')->willReturn($application);
4037

4138
$module->onBootstrap($event);
4239
}
4340

44-
4541
public function serviceLocator($service)
4642
{
4743
switch ($service) {
@@ -60,4 +56,4 @@ public function serviceLocator($service)
6056
//
6157
}
6258
}
63-
}
59+
}

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
"phpunit/phpunit": "~4.7",
3939
"zendframework/zend-console": "2.6.*",
4040
"zendframework/zend-loader": "2.5.*",
41-
"squizlabs/php_codesniffer": "^2.3.1"
41+
"squizlabs/php_codesniffer": "^2.3.1",
42+
"fabpot/php-cs-fixer": "1.9.*"
4243
},
4344
"autoload": {
4445
"psr-4": {

config/module.config.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
2+
23
/**
34
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
45
* @copyright Copyright (c) 2014 Zend Technologies USA Inc. (http://www.zend.com)
56
*/
6-
77
use ZF\ApiProblem\Factory\ApiProblemListenerFactory;
88
use ZF\ApiProblem\Factory\ApiProblemRendererFactory;
99
use ZF\ApiProblem\Factory\ApiProblemStrategyFactory;
@@ -17,25 +17,25 @@
1717

1818
return [
1919
'service_manager' => [
20-
'aliases' => [
21-
'ZF\ApiProblem\ApiProblemListener' => ApiProblemListener::class,
20+
'aliases' => [
21+
'ZF\ApiProblem\ApiProblemListener' => ApiProblemListener::class,
2222
'ZF\ApiProblem\RenderErrorListener' => RenderErrorListener::class,
23-
'ZF\ApiProblem\ApiProblemRenderer' => ApiProblemRenderer::class,
24-
'ZF\ApiProblem\ApiProblemStrategy' => ApiProblemStrategy::class,
23+
'ZF\ApiProblem\ApiProblemRenderer' => ApiProblemRenderer::class,
24+
'ZF\ApiProblem\ApiProblemStrategy' => ApiProblemStrategy::class,
2525
],
2626
'factories' => [
27-
ApiProblemListener::class => ApiProblemListenerFactory::class,
28-
RenderErrorListener::class => RenderErrorListenerFactory::class,
27+
ApiProblemListener::class => ApiProblemListenerFactory::class,
28+
RenderErrorListener::class => RenderErrorListenerFactory::class,
2929
SendApiProblemResponseListener::class => SendApiProblemResponseListenerFactory::class,
30-
ApiProblemRenderer::class => ApiProblemRendererFactory::class,
31-
ApiProblemStrategy::class => ApiProblemStrategyFactory::class,
30+
ApiProblemRenderer::class => ApiProblemRendererFactory::class,
31+
ApiProblemStrategy::class => ApiProblemStrategyFactory::class,
3232
],
3333
],
3434

3535
'view_manager' => [
3636
// Enable this in your application configuration in order to get full
3737
// exception stack traces in your API-Problem responses.
38-
'display_exceptions' => FALSE,
38+
'display_exceptions' => false,
3939
],
4040

4141
'zf-api-problem' => [

src/ApiProblem.php

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
45
* @copyright Copyright (c) 2014 Zend Technologies USA Inc. (http://www.zend.com)
@@ -7,19 +8,20 @@
78
namespace ZF\ApiProblem;
89

910
/**
10-
* Object describing an API-Problem payload
11+
* Object describing an API-Problem payload.
1112
*/
1213
class ApiProblem
1314
{
1415
/**
15-
* Additional details to include in report
16+
* Additional details to include in report.
1617
*
1718
* @var array
1819
*/
1920
protected $additionalDetails = [];
2021

2122
/**
22-
* URL describing the problem type; defaults to HTTP status codes
23+
* URL describing the problem type; defaults to HTTP status codes.
24+
*
2325
* @var string
2426
*/
2527
protected $type = 'http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html';
@@ -47,19 +49,19 @@ class ApiProblem
4749
protected $status;
4850

4951
/**
50-
* Normalized property names for overloading
52+
* Normalized property names for overloading.
5153
*
5254
* @var array
5355
*/
5456
protected $normalizedProperties = [
55-
'type' => 'type',
57+
'type' => 'type',
5658
'status' => 'status',
57-
'title' => 'title',
59+
'title' => 'title',
5860
'detail' => 'detail',
5961
];
6062

6163
/**
62-
* Status titles for common problems
64+
* Status titles for common problems.
6365
*
6466
* @var array
6567
*/
@@ -113,7 +115,7 @@ class ApiProblem
113115
protected $title;
114116

115117
/**
116-
* Constructor
118+
* Constructor.
117119
*
118120
* Create an instance using the provided information. If nothing is
119121
* provided for the type field, the class default will be used;
@@ -141,7 +143,7 @@ public function __construct($status, $detail, $type = null, $title = null, array
141143
}
142144

143145
// Ensure a valid HTTP status
144-
if (! is_numeric($status)
146+
if (!is_numeric($status)
145147
|| ($status < 100)
146148
|| ($status > 599)
147149
) {
@@ -150,7 +152,7 @@ public function __construct($status, $detail, $type = null, $title = null, array
150152

151153
$this->status = $status;
152154
$this->detail = $detail;
153-
$this->title = $title;
155+
$this->title = $title;
154156

155157
if (null !== $type) {
156158
$this->type = $type;
@@ -160,17 +162,20 @@ public function __construct($status, $detail, $type = null, $title = null, array
160162
}
161163

162164
/**
163-
* Retrieve properties
165+
* Retrieve properties.
166+
*
167+
* @param string $name
164168
*
165-
* @param string $name
166169
* @return mixed
170+
*
167171
* @throws Exception\InvalidArgumentException
168172
*/
169173
public function __get($name)
170174
{
171175
$normalized = strtolower($name);
172176
if (in_array($normalized, array_keys($this->normalizedProperties))) {
173177
$prop = $this->normalizedProperties[$normalized];
178+
174179
return $this->{$prop};
175180
}
176181

@@ -189,15 +194,15 @@ public function __get($name)
189194
}
190195

191196
/**
192-
* Cast to an array
197+
* Cast to an array.
193198
*
194199
* @return array
195200
*/
196201
public function toArray()
197202
{
198203
$problem = [
199-
'type' => $this->type,
200-
'title' => $this->getTitle(),
204+
'type' => $this->type,
205+
'title' => $this->getTitle(),
201206
'status' => $this->getStatus(),
202207
'detail' => $this->getDetail(),
203208
];
@@ -209,17 +214,19 @@ public function toArray()
209214
* Set the flag indicating whether an exception detail should include a
210215
* stack trace and previous exception information.
211216
*
212-
* @param bool $flag
217+
* @param bool $flag
218+
*
213219
* @return ApiProblem
214220
*/
215221
public function setDetailIncludesStackTrace($flag)
216222
{
217223
$this->detailIncludesStackTrace = (bool) $flag;
224+
218225
return $this;
219226
}
220227

221228
/**
222-
* Retrieve the API-Problem detail
229+
* Retrieve the API-Problem detail.
223230
*
224231
* If an exception was provided, creates the detail message from it;
225232
* otherwise, detail as provided is used.
@@ -236,7 +243,7 @@ protected function getDetail()
236243
}
237244

238245
/**
239-
* Retrieve the API-Problem HTTP status code
246+
* Retrieve the API-Problem HTTP status code.
240247
*
241248
* If an exception was provided, creates the status code from it;
242249
* otherwise, code as provided is used.
@@ -253,7 +260,7 @@ protected function getStatus()
253260
}
254261

255262
/**
256-
* Retrieve the title
263+
* Retrieve the title.
257264
*
258265
* If the default $type is used, and the $status is found in
259266
* $problemStatusTitles, then use the matching title.
@@ -309,9 +316,9 @@ protected function createDetailFromException()
309316
$e = $e->getPrevious();
310317
while ($e) {
311318
$previous[] = [
312-
'code' => (int) $e->getCode(),
319+
'code' => (int) $e->getCode(),
313320
'message' => trim($e->getMessage()),
314-
'trace' => $e->getTrace(),
321+
'trace' => $e->getTrace(),
315322
];
316323
$e = $e->getPrevious();
317324
}
@@ -329,7 +336,7 @@ protected function createDetailFromException()
329336
*/
330337
protected function createStatusFromException()
331338
{
332-
$e = $this->detail;
339+
$e = $this->detail;
333340
$status = $e->getCode();
334341

335342
if (!empty($status)) {

0 commit comments

Comments
 (0)