Skip to content

Commit 697aafe

Browse files
authored
Merge pull request #8 from ppavlovic/master
Added psr2 check and fixed code for compliance
2 parents 551cd5f + 5960057 commit 697aafe

50 files changed

Lines changed: 192 additions & 125 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

composer.json

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,49 @@
11
{
2-
"name": "g4/clean-core",
3-
"description": "clean-core php library",
4-
"keywords": [
5-
"clean core",
6-
"use case",
7-
"service",
8-
"clean architecture"
9-
],
10-
"license": "MIT",
11-
"authors": [
12-
{
13-
"name": "Drasko Gomboc",
14-
"email": "drasko.gomboc@gmail.com"
2+
"name": "g4/clean-core",
3+
"description": "clean-core php library",
4+
"keywords": [
5+
"clean core",
6+
"use case",
7+
"service",
8+
"clean architecture"
9+
],
10+
"license": "MIT",
11+
"authors": [
12+
{
13+
"name": "Drasko Gomboc",
14+
"email": "drasko.gomboc@gmail.com"
15+
},
16+
{
17+
"name": "Dejan Samardzija",
18+
"email": "samardzija.dejan@gmail.com"
19+
},
20+
{
21+
"name": "Ivan Krickovic",
22+
"email": "ivan.krickovic@gmail.com"
23+
}
24+
],
25+
"autoload": {
26+
"psr-4": {
27+
"G4\\CleanCore\\": "src/"
28+
}
1529
},
16-
{
17-
"name": "Dejan Samardzija",
18-
"email": "samardzija.dejan@gmail.com"
30+
"require-dev": {
31+
"phpunit/phpunit": "3.7.*",
32+
"rector/rector": "^0.14.6",
33+
"squizlabs/php_codesniffer": "^3.7"
1934
},
20-
{
21-
"name": "Ivan Krickovic",
22-
"email": "ivan.krickovic@gmail.com"
35+
"require": {
36+
"php": ">=7.3",
37+
"ext-json": "*",
38+
"g4/constants": "*",
39+
"zendframework/zend-paginator": "2.*"
40+
},
41+
"scripts": {
42+
"psr2-check": [
43+
"./vendor/bin/phpcs --standard=PSR2 src/"
44+
],
45+
"psr2-fix": [
46+
"./vendor/bin/phpcbf --standard=PSR2 src/"
47+
]
2348
}
24-
],
25-
"autoload": {
26-
"psr-4": {"G4\\CleanCore\\": "src/"}
27-
},
28-
"require-dev": {
29-
"phpunit/phpunit": "3.7.*",
30-
"rector/rector": "^0.14.6"
31-
},
32-
"require": {
33-
"php": ">=7.3",
34-
"ext-json": "*",
35-
"g4/constants": "*",
36-
"zendframework/zend-paginator": "2.*"
37-
}
3849
}

composer.lock

Lines changed: 59 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function run(): self
9191
$this
9292
->initBootstrap()
9393
->runFrontController();
94-
} catch(\Exception $exception) {
94+
} catch (\Exception $exception) {
9595
$this->getError()
9696
->setException($exception)
9797
->setResponse($this->getResponse())

src/Bootstrap/BootstrapAbstract.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ public function getRequest(): \G4\CleanCore\Request\Request
2121
{
2222
return $this->request;
2323
}
24-
}
24+
}

src/Bootstrap/BootstrapInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ interface BootstrapInterface
66
{
77
public function init();
88
public function getAllowedMedia();
9-
}
9+
}

src/Bootstrap/Factory.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Factory
1919
/**
2020
* @var \G4\CleanCore\Request\Request
2121
*/
22-
private $_request;
22+
private $request;
2323

2424
public function initBootstrap(): void
2525
{
@@ -46,7 +46,7 @@ public function setAppNamespace(string $appNamespace): self
4646

4747
public function setRequest(Request $request): self
4848
{
49-
$this->_request = $request;
49+
$this->request = $request;
5050
return $this;
5151
}
5252

@@ -67,8 +67,8 @@ private function bootstrapFactory(): void
6767
$bootstrapName = $this->fullBootstrapName;
6868
$this->bootstrap = new $bootstrapName();
6969
$this->bootstrap
70-
->setRequest($this->_request)
70+
->setRequest($this->request)
7171
->init();
7272
}
7373
}
74-
}
74+
}

src/Controller/Front.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public function run(): void
5151
$this->dispatcher->isDispatchable()
5252
? $this->dispatch()
5353
: $this->response->setHttpResponseCode(404);
54-
5554
}
5655

5756
public function setAppNamespace($appNamespace): self
@@ -88,4 +87,4 @@ private function dispatch(): void
8887

8988
$this->response = $this->service->getFormattedResponse();
9089
}
91-
}
90+
}

src/Dispatcher/Dispatcher.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ public function setRequest(Request $request): self
5151
return $this;
5252
}
5353

54-
/**
55-
* @param string $serviceNamespace
56-
*/
5754
public function setAppNamespace(string $appNamespace): self
5855
{
5956
$this->appNamespace = $appNamespace;
@@ -62,7 +59,12 @@ public function setAppNamespace(string $appNamespace): self
6259

6360
private function constructFullServiceName(): self
6461
{
65-
$this->fullServiceName = join('\\', [$this->appNamespace, 'Service', $this->getServiceName(), $this->getClassName()]);
62+
$this->fullServiceName = implode('\\', [
63+
$this->appNamespace,
64+
'Service',
65+
$this->getServiceName(),
66+
$this->getClassName()
67+
]);
6668
return $this;
6769
}
6870

@@ -74,8 +76,9 @@ private function getClassName(): string
7476
private function getServiceName(): string
7577
{
7678
return ucfirst(
77-
preg_replace_callback('/-([a-z])/',
78-
function($matches): string {
79+
preg_replace_callback(
80+
'/-([a-z])/',
81+
function ($matches): string {
7982
return strtoupper($matches[1]);
8083
},
8184
$this->request->getResourceName()
@@ -95,4 +98,4 @@ private function serviceFactory(): void
9598
$this->service = new $serviceName();
9699
}
97100
}
98-
}
101+
}

src/Error/Validation.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ private function addMessage(\G4\CleanCore\Exception\Validation $exception): void
4444

4545
private function iterateTroughExceptions(): void
4646
{
47-
foreach($this->exceptions as $oneException)
48-
{
47+
foreach ($this->exceptions as $oneException) {
4948
$this->addMessage($oneException);
5049
}
5150
}
52-
}
51+
}

src/Exception/Validation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ public function getValue()
2626
{
2727
return $this->value;
2828
}
29-
}
29+
}

0 commit comments

Comments
 (0)