Skip to content

Commit 287e499

Browse files
committed
Moved repository and renamed package.
1 parent 30326ef commit 287e499

19 files changed

+181
-176
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ABC-Framework: Core Exception Handler
1+
# PhpPlaisio: Core Exception Handler
22

33
<table>
44
<thead>
@@ -13,20 +13,20 @@
1313
<tbody>
1414
<tr>
1515
<td>
16-
<a href="https://gitter.im/SetBased/php-abc?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge"><img src="https://badges.gitter.im/SetBased/php-abc.svg" alt="Gitter"/></a>
16+
<a href="https://gitter.im/PhpPlaisio/PhpPlaisio"><img src="https://badges.gitter.im/PhpPlaisio/PhpPlaisio.svg" alt="Gitter"/></a>
1717
</td>
1818
<td>
19-
<a href="https://packagist.org/packages/setbased/abc-exception-handler-core"><img src="https://poser.pugx.org/setbased/abc-exception-handler-core/license" alt="License"/></a>
19+
<a href="https://packagist.org/packages/plaisio/exception-handler-core"><img src="https://poser.pugx.org/plaisio/exception-handler-core/license" alt="License"/></a>
2020
</td>
2121
<td>
22-
<a href="https://packagist.org/packages/setbased/abc-exception-handler-core"><img src="https://poser.pugx.org/setbased/abc-exception-handler-core/v/stable" alt="Latest Stable Version"/></a>
22+
<a href="https://packagist.org/packages/plaisio/exception-handler-core"><img src="https://poser.pugx.org/plaisio/exception-handler-core/v/stable" alt="Latest Stable Version"/></a>
2323
</td>
2424
<td>
25-
<a href="https://travis-ci.org/SetBased/php-abc-exception-handler-core"><img src="https://travis-ci.org/SetBased/php-abc-exception-handler-core.svg?branch=master" alt="Build Status"/></a><br/>
26-
<a href="https://scrutinizer-ci.com/g/SetBased/php-abc-exception-handler-core/?branch=master"><img src="https://scrutinizer-ci.com/g/SetBased/php-abc-exception-handler-core/badges/coverage.png?b=master" alt="Code Coverage"/></a>
25+
<a href="https://travis-ci.org/PhpPlaisio/exception-handler-core"><img src="https://travis-ci.org/PhpPlaisio/exception-handler-core.svg?branch=master" alt="Build Status"/></a><br/>
26+
<a href="https://scrutinizer-ci.com/g/PhpPlaisio/exception-handler-core/?branch=master"><img src="https://scrutinizer-ci.com/g/PhpPlaisio/exception-handler-core/badges/coverage.png?b=master" alt="Code Coverage"/></a>
2727
</td>
2828
<td>
29-
<a href="https://scrutinizer-ci.com/g/SetBased/php-abc-exception-handler-core/?branch=master"><img src="https://scrutinizer-ci.com/g/SetBased/php-abc-exception-handler-core/badges/quality-score.png?b=master" alt="Scrutinizer Code Quality"/></a>
29+
<a href="https://scrutinizer-ci.com/g/PhpPlaisio/exception-handler-core/?branch=master"><img src="https://scrutinizer-ci.com/g/PhpPlaisio/exception-handler-core/badges/quality-score.png?b=master" alt="Scrutinizer Code Quality"/></a>
3030
</td>
3131
</tr>
3232
</tbody>

abc.xml

Lines changed: 0 additions & 5 deletions
This file was deleted.

build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<project name="ABC-Framework" default="build" basedir=".">
1+
<project name="PhpPlaisio" default="build" basedir=".">
22
<!-- Run composer update and executes various other updates -->
33
<target name="update">
44
<exec command="composer update" checkreturn="true" passthru="true"/>

composer.json

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,32 @@
11
{
2-
"name": "setbased/abc-exception-handler-core",
3-
"description": "ABC-Framework: Core Exception Handler",
2+
"name": "plaisio/exception-handler-core",
3+
"description": "PhpPlaisio: Core Exception Handler",
44
"keywords": [
5-
"ABC-Framework",
6-
"Exception",
7-
"Handling",
8-
"Core"
5+
"PhpPlaisio",
6+
"Exception Handler"
97
],
10-
"type": "library",
118
"license": "MIT",
129
"require": {
1310
"php": ">=7.1.0",
1411
"ext-dom": "*",
1512
"ext-libxml": "*",
1613
"composer/composer": "^1.0.0",
17-
"setbased/abc": "*",
18-
"setbased/abc-http-header": "^2.0.2",
19-
"setbased/abc-exception": "^2.0.0",
20-
"setbased/abc-exception-handler": "^1.0.0",
14+
"plaisio/exception": "^1.0.0",
15+
"plaisio/exception-handler": "^1.0.0",
16+
"plaisio/kernel": "^1.0.0",
17+
"plaisio/response-core": "^1.0.0",
2118
"setbased/helper-code-store-php": "^2.1.1",
2219
"setbased/php-stratum-middle": "^5.0.0",
2320
"symfony/console": "^4.0.0"
2421
},
2522
"require-dev": {
2623
"phing/phing": "^2.0.0",
2724
"phpunit/phpunit": "^7.0.0 || ^8.0.0",
28-
"setbased/abc-console": "*"
25+
"plaisio/console": "^0.2.0"
2926
},
3027
"autoload": {
3128
"psr-4": {
32-
"SetBased\\Abc\\ExceptionHandler\\": "src/"
29+
"Plaisio\\ExceptionHandler\\": "src/"
3330
}
3431
},
3532
"config": {

plaisio.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<plaisio>
2+
<commands>
3+
<command name="plaisio:generate-core-exception-handler">\Plaisio\ExceptionHandler\Command\GenerateExceptionHandlerCommand</command>
4+
</commands>
5+
</plaisio>

src/BadRequestExceptionAgent.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22
declare(strict_types=1);
33

4-
namespace SetBased\Abc\ExceptionHandler;
4+
namespace Plaisio\ExceptionHandler;
55

6-
use SetBased\Abc\Abc;
7-
use SetBased\Abc\Exception\BadRequestException;
8-
use SetBased\Abc\Helper\HttpHeader;
6+
use Plaisio\Exception\BadRequestException;
7+
use Plaisio\Kernel\Nub;
8+
use Plaisio\Response\BadRequestResponse;
99

1010
/**
1111
* An agent that handles BadRequestException exceptions.
@@ -14,7 +14,7 @@ class BadRequestExceptionAgent
1414
{
1515
//--------------------------------------------------------------------------------------------------------------------
1616
/**
17-
* Handles a InvalidUrlException thrown in the constructor of a page object.
17+
* Handles a BadRequestException thrown in the constructor of a page object.
1818
*
1919
* @param BadRequestException $exception The exception.
2020
*
@@ -56,25 +56,26 @@ public function handleResponseException(BadRequestException $exception): void
5656

5757
//--------------------------------------------------------------------------------------------------------------------
5858
/**
59-
* Handles an BadRequestException.
59+
* Handles a BadRequestException.
6060
*
6161
* @param BadRequestException $exception The exception.
6262
*/
6363
private function handleException(BadRequestException $exception): void
6464
{
65-
Abc::$DL->rollback();
65+
Nub::$DL->rollback();
6666

6767
// Set the HTTP status to 400 (Bad Request).
68-
HttpHeader::clientErrorBadRequest();
68+
$response = new BadRequestResponse();
69+
$response->send();
6970

7071
// Log the bad request.
71-
Abc::$requestLogger->logRequest(HttpHeader::$status);
72-
Abc::$DL->commit();
72+
Nub::$requestLogger->logRequest($response->getStatus());
73+
Nub::$DL->commit();
7374

7475
// Only on development environment log the error.
75-
if (Abc::$request->isEnvDev())
76+
if (Nub::$request->isEnvDev())
7677
{
77-
$logger = Abc::$abc->getErrorLogger();
78+
$logger = Nub::$nub->getErrorLogger();
7879
$logger->logError($exception);
7980
}
8081
}

src/Command/GenerateExceptionHandlerCommand.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22
declare(strict_types=1);
33

4-
namespace SetBased\Abc\ExceptionHandler\Command;
4+
namespace Plaisio\ExceptionHandler\Command;
55

66
use Composer\IO\ConsoleIO;
7-
use SetBased\Abc\Console\Style\AbcStyle;
8-
use SetBased\Abc\ExceptionHandler\Helper\AbcXmlHelper;
9-
use SetBased\Abc\ExceptionHandler\Helper\ExceptionHandlerCodeGenerator;
10-
use SetBased\Abc\ExceptionHandler\Helper\ExceptionHandlerMetadataExtractor;
7+
use Plaisio\Console\Style\PlaisioStyle;
8+
use Plaisio\ExceptionHandler\Helper\ExceptionHandlerCodeGenerator;
9+
use Plaisio\ExceptionHandler\Helper\ExceptionHandlerMetadataExtractor;
10+
use Plaisio\ExceptionHandler\Helper\PlaisioXmlHelper;
1111
use Symfony\Component\Console\Command\Command;
1212
use Symfony\Component\Console\Formatter\OutputFormatter;
1313
use Symfony\Component\Console\Input\InputArgument;
@@ -30,7 +30,7 @@ class GenerateExceptionHandlerCommand extends Command
3030
/**
3131
* The output decorator.
3232
*
33-
* @var AbcStyle
33+
* @var PlaisioStyle
3434
*/
3535
private $io;
3636

@@ -40,7 +40,7 @@ class GenerateExceptionHandlerCommand extends Command
4040
*/
4141
protected function configure()
4242
{
43-
$this->setName('abc:generate-core-exception-handler')
43+
$this->setName('plaisio:generate-core-exception-handler')
4444
->setDescription('Generates the code for the core\'s exception handler')
4545
->addArgument('config file', InputArgument::OPTIONAL, 'The abc.xml configuration file', 'abc.xml');
4646
}
@@ -51,13 +51,13 @@ protected function configure()
5151
*/
5252
protected function execute(InputInterface $input, OutputInterface $output)
5353
{
54-
$this->io = new AbcStyle($input, $output);
54+
$this->io = new PlaisioStyle($input, $output);
5555
$this->consoleIo = new ConsoleIO($input, $output, $this->getHelperSet());
5656

5757
$metadataExtractor = new ExceptionHandlerMetadataExtractor($this->io, $input->getArgument('config file'));
5858
$handlers = $metadataExtractor->extractExceptionAgents();
5959

60-
$xmlHelper = new AbcXmlHelper($input->getArgument('config file'));
60+
$xmlHelper = new PlaisioXmlHelper($input->getArgument('config file'));
6161
[$class, $path] = $xmlHelper->extractExceptionHandlerClass();
6262

6363
$generator = new ExceptionHandlerCodeGenerator();

src/Helper/ExceptionHandlerCodeGenerator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
declare(strict_types=1);
33

4-
namespace SetBased\Abc\ExceptionHandler\Helper;
4+
namespace Plaisio\ExceptionHandler\Helper;
55

66
use SetBased\Helper\CodeStore\PhpCodeStore;
77

@@ -40,7 +40,7 @@ public function generateCode(string $class, array $allAgents): string
4040
{
4141
$parts = explode('\\', $class);
4242
$class = array_pop($parts);
43-
$namespace = implode('\\', $parts);
43+
$namespace = ltrim(implode('\\', $parts), '\\');
4444

4545
$this->generateHeader($namespace);
4646
$this->generateClass($class, $allAgents);
@@ -84,7 +84,7 @@ private function generateHeader(string $namespace): void
8484
$this->store->append('');
8585
$this->store->append(sprintf('namespace %s;', $namespace));
8686
$this->store->append('');
87-
$this->store->append('use SetBased\Abc\ExceptionHandler\ExceptionHandler;');
87+
$this->store->append('use Plaisio\ExceptionHandler\ExceptionHandler;');
8888
$this->store->append('');
8989
}
9090

src/Helper/ExceptionHandlerMetadataExtractor.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22
declare(strict_types=1);
33

4-
namespace SetBased\Abc\ExceptionHandler\Helper;
4+
namespace Plaisio\ExceptionHandler\Helper;
55

6-
use SetBased\Abc\Console\Style\AbcStyle;
6+
use Plaisio\Console\Style\PlaisioStyle;
77

88
/**
99
* Command for generation the code for the core's exception handler.
@@ -28,7 +28,7 @@ class ExceptionHandlerMetadataExtractor
2828
/**
2929
* The output decorator.
3030
*
31-
* @var AbcStyle
31+
* @var PlaisioStyle
3232
*/
3333
private $io;
3434

@@ -43,14 +43,13 @@ class ExceptionHandlerMetadataExtractor
4343
'handleFinalizeException'];
4444

4545
//--------------------------------------------------------------------------------------------------------------------
46-
4746
/**
4847
* ExceptionHandlerMetadataExtractor constructor.
4948
*
50-
* @param AbcStyle $io The output decorator.
51-
* @param string $configFilename The path of the abc.xml config file.
49+
* @param PlaisioStyle $io The output decorator.
50+
* @param string $configFilename The path of the abc.xml config file.
5251
*/
53-
public function __construct(AbcStyle $io, string $configFilename)
52+
public function __construct(PlaisioStyle $io, string $configFilename)
5453
{
5554
$this->io = $io;
5655
$this->configFilename = $configFilename;
@@ -64,6 +63,8 @@ public function __construct(AbcStyle $io, string $configFilename)
6463
* @param array $agent2 The second agent.
6564
*
6665
* @return int
66+
*
67+
* @throws \ReflectionException
6768
*/
6869
public static function compareAgents(array $agent1, array $agent2): int
6970
{
@@ -220,7 +221,7 @@ private function readExceptionAgents(): array
220221
throw new \RuntimeException(sprintf('File %s not found', $this->configFilename));
221222
}
222223

223-
$helper = new AbcXmlHelper($this->configFilename);
224+
$helper = new PlaisioXmlHelper($this->configFilename);
224225
$agents = $helper->extractExceptionAgents();
225226

226227
return $agents;
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
<?php
22
declare(strict_types=1);
33

4-
namespace SetBased\Abc\ExceptionHandler\Helper;
4+
namespace Plaisio\ExceptionHandler\Helper;
55

66
use SetBased\Exception\RuntimeException;
77

88
/**
9-
* Helper class for retrieving information about abc.xml files.
9+
* Helper class for retrieving information about plaisio.xml files.
1010
*/
11-
class AbcXmlHelper
11+
class PlaisioXmlHelper
1212
{
1313
//--------------------------------------------------------------------------------------------------------------------
1414
/**
15-
* The path to the abc.xml file.
15+
* The path to the plaisio.xml file.
1616
*
1717
* @var string
1818
*/
1919
private $path;
2020

2121
/**
22-
* The XML of the abc.xml.
22+
* The XML of the plaisio.xml.
2323
*
2424
* @var \DOMDocument
2525
*/
2626
private $xml;
2727

2828
//--------------------------------------------------------------------------------------------------------------------
2929
/**
30-
* AbcXmlHelper constructor.
30+
* PlaisioXmlHelper constructor.
3131
*
32-
* @param string $path The path to the abc.xml file.
32+
* @param string $path The path to the plaisio.xml file.
3333
*/
3434
public function __construct(string $path)
3535
{
@@ -45,7 +45,7 @@ public function __construct(string $path)
4545

4646
//--------------------------------------------------------------------------------------------------------------------
4747
/**
48-
* Returns the exception agents found in the abc.xml file.
48+
* Returns the exception agents found in the plaisio.xml file.
4949
*
5050
* @return string[]
5151
*/
@@ -54,7 +54,7 @@ public function extractExceptionAgents(): array
5454
$classes = [];
5555

5656
$xpath = new \DOMXpath($this->xml);
57-
$list = $xpath->query('/abc/exception/agents/agent');
57+
$list = $xpath->query('/plaisio/exception/agents/agent');
5858
foreach ($list as $item)
5959
{
6060
$classes[] = $item->nodeValue;
@@ -73,10 +73,10 @@ public function extractExceptionHandlerClass(): array
7373
{
7474
$xpath = new \DOMXpath($this->xml);
7575

76-
$list = $xpath->query('/abc/exception/class');
76+
$list = $xpath->query('/plaisio/exception/class');
7777
$class = $list[0]->nodeValue;
7878

79-
$list = $xpath->query('/abc/exception/path');
79+
$list = $xpath->query('/plaisio/exception/path');
8080
$path = $list[0]->nodeValue;
8181

8282
return [$class, $path];

0 commit comments

Comments
 (0)