Skip to content

Commit 263dd88

Browse files
committed
Code cleanup + Directories Reorganization
1 parent adc2b31 commit 263dd88

29 files changed

+102
-359
lines changed

.travis.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ dist: trusty
44

55
matrix:
66
include:
7-
- php: 7.2
8-
- php: 7.3
9-
- php: 7.4
10-
env: ANALYSIS='true'
11-
- php: nightly
7+
- php: 7.2
8+
- php: 7.3
9+
- php: 7.4
10+
env: ANALYSIS='true'
11+
- php: nightly
1212

1313
allow_failures:
14-
- php: nightly
14+
- php: nightly
1515

1616
before_script:
17-
- composer require php-coveralls/php-coveralls:^2.2.0
18-
- composer install -n
17+
- composer require php-coveralls/php-coveralls:^2.2.0
18+
- composer install -n
1919

2020
script:
21-
- if [[ "$ANALYSIS" == 'true' ]]; then vendor/bin/phpunit --coverage-clover clover.xml ; fi
22-
- if [[ "$ANALYSIS" == 'true' ]]; then vendor/bin/phpstan analyse src ; fi
21+
- if [[ "$ANALYSIS" == 'true' ]]; then vendor/bin/phpunit --coverage-clover clover.xml ; fi
22+
- if [[ "$ANALYSIS" == 'true' ]]; then vendor/bin/phpstan analyse src ; fi
2323

2424
after_success:
25-
- if [[ "$ANALYSIS" == 'true' ]]; then vendor/bin/php-coveralls --coverage_clover=clover.xml -v ; fi
25+
- if [[ "$ANALYSIS" == 'true' ]]; then vendor/bin/php-coveralls --coverage_clover=clover.xml -v ; fi

app/routes.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,8 @@
22

33
declare(strict_types=1);
44

5-
use App\Application\Action\User\ListUsersAction;
6-
use App\Application\Action\User\ViewUserAction;
7-
use App\Application\Action\User\UserCreateAction;
8-
use Psr\Http\Message\ResponseInterface as Response;
9-
use Psr\Http\Message\ServerRequestInterface as Request;
5+
use App\Action\User\UserCreateAction;
106
use Slim\App;
11-
use Slim\Interfaces\RouteCollectorProxyInterface as Group;
127

138
return function (App $app) {
149
$app->get('/', \App\Action\HomeAction::class)->setName('home');

docker-compose.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
version: '3.7'
22

33
volumes:
4-
logs:
5-
driver: local
4+
logs:
5+
driver: local
66

77
services:
8-
slim:
9-
image: php:7-alpine
10-
working_dir: /var/www
11-
command: php -S 0.0.0.0:8080 -t public
12-
environment:
13-
docker: "true"
14-
ports:
15-
- 8080:8080
16-
volumes:
17-
- .:/var/www
18-
- logs:/var/www/logs
8+
slim:
9+
image: php:7-alpine
10+
working_dir: /var/www
11+
command: php -S 0.0.0.0:8080 -t public
12+
environment:
13+
docker: "true"
14+
ports:
15+
- 8080:8080
16+
volumes:
17+
- .:/var/www
18+
- logs:/var/www/logs

phpunit.xml.dist

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<phpunit
2-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/7.1/phpunit.xsd"
4-
backupGlobals="false"
5-
backupStaticAttributes="false"
6-
beStrictAboutTestsThatDoNotTestAnything="true"
7-
beStrictAboutChangesToGlobalState="true"
8-
beStrictAboutOutputDuringTests="true"
9-
colors="true"
10-
convertErrorsToExceptions="true"
11-
convertNoticesToExceptions="true"
12-
convertWarningsToExceptions="true"
13-
processIsolation="false"
14-
stopOnFailure="false"
15-
bootstrap="tests/bootstrap.php"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/7.1/phpunit.xsd"
4+
backupGlobals="false"
5+
backupStaticAttributes="false"
6+
beStrictAboutTestsThatDoNotTestAnything="true"
7+
beStrictAboutChangesToGlobalState="true"
8+
beStrictAboutOutputDuringTests="true"
9+
colors="true"
10+
convertErrorsToExceptions="true"
11+
convertNoticesToExceptions="true"
12+
convertWarningsToExceptions="true"
13+
processIsolation="false"
14+
stopOnFailure="false"
15+
bootstrap="tests/bootstrap.php"
1616
>
1717
<testsuites>
1818
<testsuite name="Test Suite">

public/index.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
use App\Application\Handler\ShutdownHandler;
66
use App\Application\ResponseEmitter\ResponseEmitter;
77
use App\Application\Setting\SettingsInterface;
8-
use DI\ContainerBuilder;
9-
use Slim\Factory\AppFactory;
10-
use Slim\Factory\ServerRequestCreatorFactory;
118

129
require __DIR__ . '/../vendor/autoload.php';
1310

src/Action/Action.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ protected function getFormData()
8484
}
8585

8686
/**
87-
* @param string $name
87+
* @param string $name
8888
* @return mixed
8989
* @throws HttpBadRequestException
9090
*/
@@ -119,7 +119,7 @@ protected function respond(ActionPayload $payload): Response
119119
$this->response->getBody()->write($json);
120120

121121
return $this->response
122-
->withHeader('Content-Type', 'application/json')
123-
->withStatus($payload->getStatusCode());
122+
->withHeader('Content-Type', 'application/json')
123+
->withStatus($payload->getStatusCode());
124124
}
125125
}

src/Action/ActionError.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class ActionError implements JsonSerializable
2828
private $description;
2929

3030
/**
31-
* @param string $type
32-
* @param string|null $description
31+
* @param string $type
32+
* @param string|null $description
3333
*/
3434
public function __construct(string $type, ?string $description)
3535
{

src/Action/ActionPayload.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,16 @@ class ActionPayload implements JsonSerializable
2323
private $error;
2424

2525
/**
26-
* @param int $statusCode
27-
* @param array|object|null $data
28-
* @param ActionError|null $error
26+
* @param int $statusCode
27+
* @param array|object|null $data
28+
* @param ActionError|null $error
2929
*/
3030
public function __construct(
3131
int $statusCode = 200,
3232
$data = null,
3333
?ActionError $error = null
34-
) {
34+
)
35+
{
3536
$this->statusCode = $statusCode;
3637
$this->data = $data;
3738
$this->error = $error;

src/Action/HomeAction.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace App\Action;
66

7+
use PH7\JustHttp\StatusCode;
78
use Psr\Http\Message\ResponseInterface;
89
use Psr\Http\Message\ServerRequestInterface;
910

@@ -12,11 +13,12 @@ final class HomeAction
1213
public function __invoke(
1314
ServerRequestInterface $request,
1415
ResponseInterface $response
15-
): ResponseInterface {
16+
): ResponseInterface
17+
{
1618
$response->getBody()->write(json_encode(['success' => true]));
1719

1820
return $response
1921
->withHeader('Content-Type', 'application/json')
20-
->withStatus(422);
22+
->withStatus(StatusCode::CREATED);
2123
}
2224
}

src/Action/User/UserAction.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ abstract class UserAction extends Action
2020
*/
2121
public function __construct(LoggerInterface $logger,
2222
UserRepository $userRepository
23-
) {
23+
)
24+
{
2425
parent::__construct($logger);
2526
$this->userRepository = $userRepository;
2627
}

0 commit comments

Comments
 (0)