Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
275 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
/.idea | ||
.ecs_cache | ||
phpunit.xml | ||
.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Umbrellio\Postgres\Extensions; | ||
|
||
/** | ||
* @codeCoverageIgnore | ||
*/ | ||
abstract class AbstractComponent | ||
{ | ||
final public function __construct() | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Umbrellio\Postgres\Extensions; | ||
|
||
use Illuminate\Support\Traits\Macroable; | ||
use Umbrellio\Postgres\Extensions\Exceptions\MacroableMissedException; | ||
use Umbrellio\Postgres\Extensions\Exceptions\MixinInvalidException; | ||
|
||
/** | ||
* @codeCoverageIgnore | ||
*/ | ||
abstract class AbstractExtension extends AbstractComponent | ||
{ | ||
abstract public static function getMixins(): array; | ||
|
||
abstract public static function getName(): string; | ||
|
||
public static function getTypes(): array | ||
{ | ||
return []; | ||
} | ||
|
||
final public static function register(): void | ||
{ | ||
collect(static::getMixins())->each(static function ($mixin, $extension) { | ||
if (!is_subclass_of($mixin, AbstractComponent::class)) { | ||
throw new MixinInvalidException(sprintf( | ||
'Mixed class %s is not descendant of %s.', | ||
$mixin, | ||
AbstractComponent::class | ||
)); | ||
} | ||
if (!method_exists($extension, 'mixin')) { | ||
throw new MacroableMissedException(sprintf('Class %s doesn’t use Macroable Trait.', $extension)); | ||
} | ||
/** @var Macroable $extension */ | ||
$extension::mixin(new $mixin()); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Umbrellio\Postgres\Extensions\Connectors; | ||
|
||
use Umbrellio\Postgres\Extensions\AbstractComponent; | ||
use Umbrellio\Postgres\PostgresConnection; | ||
|
||
/** | ||
* @mixin PostgresConnection | ||
*/ | ||
abstract class AbstractConnection extends AbstractComponent | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Umbrellio\Postgres\Extensions\Exceptions; | ||
|
||
use Exception; | ||
|
||
class ExtensionInvalidException extends Exception | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Umbrellio\Postgres\Extensions\Exceptions; | ||
|
||
use Exception; | ||
|
||
class MacroableMissedException extends Exception | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Umbrellio\Postgres\Extensions\Exceptions; | ||
|
||
use Exception; | ||
|
||
class MixinInvalidException extends Exception | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Umbrellio\Postgres\Extensions\Schema; | ||
|
||
use Umbrellio\Postgres\Extensions\AbstractComponent; | ||
use Umbrellio\Postgres\Schema\Blueprint; | ||
|
||
/** | ||
* @mixin Blueprint | ||
*/ | ||
abstract class AbstractBlueprint extends AbstractComponent | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Umbrellio\Postgres\Extensions\Schema; | ||
|
||
use Umbrellio\Postgres\Extensions\AbstractComponent; | ||
use Umbrellio\Postgres\Schema\Builder; | ||
|
||
/** | ||
* @mixin Builder | ||
*/ | ||
abstract class AbstractBuilder extends AbstractComponent | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Umbrellio\Postgres\Extensions\Schema\Grammar; | ||
|
||
use Umbrellio\Postgres\Extensions\AbstractComponent; | ||
use Umbrellio\Postgres\Schema\Grammars\PostgresGrammar; | ||
|
||
/** | ||
* @mixin PostgresGrammar | ||
*/ | ||
abstract class AbstractGrammar extends AbstractComponent | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters