Skip to content

Commit

Permalink
Merge branch 'release/v0.5.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
betterthanclay committed Sep 30, 2020
2 parents 9ac1afd + eb21fe0 commit f6add46
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 15 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v0.5.3 (2020-09-30)
* Switched to Exceptional for exception generation

## v0.5.2 (2020-09-25)
* Switched to Glitch Dumpable interface

Expand Down
10 changes: 7 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@
}],
"require": {
"php": "^7.2",
"decodelabs/glitch": "^0.15.6"

"decodelabs/exceptional": "^0.2",
"decodelabs/glitch": "^0.15.6",

"psr/container": "^1"
},
"require-dev": {
"phpunit/phpunit": "^8",
"phpstan/phpstan": "^0.11.16",
"decodelabs/phpstan-decodelabs": "^0.2"
"phpstan/phpstan": "^0.12.19",
"decodelabs/phpstan-decodelabs": "^0.3"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ includes:
parameters:
paths:
- src
level: max
level: 5
ignoreErrors:
- '#Access to an undefined static property DecodeLabs\\Veneer\\Facade::\$instance#'
22 changes: 15 additions & 7 deletions src/Veneer/Binding.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
declare(strict_types=1);
namespace DecodeLabs\Veneer;

use DecodeLabs\Glitch\Exception\Factory as Glitch;
use Psr\Container\ContainerInterface;

use DecodeLabs\Glitch\Dumpable;
use DecodeLabs\Exceptional;

use Psr\Container\ContainerInterface;

class Binding
{
Expand Down Expand Up @@ -51,7 +51,9 @@ public function bindInstance(?ContainerInterface $container): Binding
}

if (!$instance) {
throw Glitch::ERuntime('Could not get instance of '.$this->key.' to bind to', null, $this);
throw Exceptional::Runtime(
'Could not get instance of '.$this->key.' to bind to', null, $this
);
}

if ($instance instanceof FacadeTarget) {
Expand Down Expand Up @@ -224,7 +226,9 @@ public function getNamespace(): ?string
public function getTarget(): object
{
if (!$this->target) {
throw Glitch::ERuntime('Facade '.$this->name.' has not been bound to target yet', null, $this);
throw Exceptional::Runtime(
'Facade '.$this->name.' has not been bound to target yet', null, $this
);
}

return $this->target;
Expand All @@ -236,7 +240,9 @@ public function getTarget(): object
public function getPluginNames(): array
{
if (!$this->target) {
throw Glitch::ERuntime('Facade '.$this->name.' has not been bound to target yet', null, $this);
throw Exceptional::Runtime(
'Facade '.$this->name.' has not been bound to target yet', null, $this
);
}

return $this->pluginNames;
Expand All @@ -248,7 +254,9 @@ public function getPluginNames(): array
public function hasPlugin(string $name): bool
{
if (!$this->target) {
throw Glitch::ERuntime('Facade '.$this->name.' has not been bound to target yet', null, $this);
throw Exceptional::Runtime(
'Facade '.$this->name.' has not been bound to target yet', null, $this
);
}

return in_array($name, $this->pluginNames);
Expand Down
6 changes: 4 additions & 2 deletions src/Veneer/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use DecodeLabs\Veneer\Listener;
use DecodeLabs\Veneer\Listener\Autoload;

use DecodeLabs\Glitch\Exception\Factory as Glitch;
use DecodeLabs\Exceptional;

class Context implements FacadeTarget
{
Expand Down Expand Up @@ -141,6 +141,8 @@ public function get(string $name)
}
}

throw Glitch::EInvalidArgument($name.' has not been bound as a Facade');
throw Exceptional::InvalidArgument(
$name.' has not been bound as a Facade'
);
}
}
10 changes: 8 additions & 2 deletions src/Veneer/FacadeTargetTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
namespace DecodeLabs\Veneer;

use DecodeLabs\Veneer\Register;
use DecodeLabs\Exceptional;

use Psr\Container\ContainerInterface;

trait FacadeTargetTrait
Expand All @@ -19,7 +21,9 @@ public static function registerFacade(string ...$autoBind): void
$class = get_called_class();

if (!defined($class.'::FACADE')) {
throw Glitch::ESetup('Facade target '.$class.' has not defined the facade name', null, $class);
throw Exceptional::Setup(
'Facade target '.$class.' has not defined the facade name', null, $class
);
}

$name = $class::FACADE;
Expand Down Expand Up @@ -57,6 +61,8 @@ public function getFacadePluginNames(): array
*/
public function loadFacadePlugin(string $name): FacadePlugin
{
throw Glitch::EImplementation('Facade target has not implemented a plugin loader', null, $this);
throw Exceptional::Implementation(
'Facade target has not implemented a plugin loader', null, $this
);
}
}
6 changes: 6 additions & 0 deletions src/Veneer/ListenerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
namespace DecodeLabs\Veneer;

use DecodeLabs\Veneer\Manager\Aliasing;
use DecodeLabs\Exceptional;

use Psr\Container\ContainerInterface;

trait ListenerTrait
Expand Down Expand Up @@ -62,6 +64,10 @@ public function getDefaultManager(): Manager
foreach ($this->managers as $manager) {
return $manager;
}

throw Exceptional::Runtime(
'No default manager available'
);
}
}

Expand Down

0 comments on commit f6add46

Please sign in to comment.