Skip to content

Commit

Permalink
prepare for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
danubackstage committed Dec 10, 2023
1 parent 426494c commit aa19abc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
parameters:
level: 1
level: 2
paths:
- src
13 changes: 9 additions & 4 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Container implements ContainerContract
* @var array
*/
private array $services = [];

/**
* The container's instance.
*
Expand All @@ -34,16 +35,16 @@ class Container implements ContainerContract
public static function instance(): static
{

if (is_null(static::$instance)) {
static::$instance = new static();
if (!isset(self::$instance)) {
self::$instance = new self();
}

return static::$instance;
return self::$instance;
}

/**
* @param string $id
* @param object $service
* @return object
*/
public function get(string $id): object
{
Expand Down Expand Up @@ -152,4 +153,8 @@ private function __construct()
private function __clone(): void
{
}

private function __wakeup()
{
}
}
8 changes: 1 addition & 7 deletions src/Contracts/ContainerContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,14 @@ interface ContainerContract
*
* @param string $id Identifier of the entry to look for.
*
* @throws NotFoundExceptionInterface No entry was found for **this** identifier.
* @throws ContainerExceptionInterface Error while retrieving the entry.
*
* @return mixed Entry.
*/
public function get(string $id): mixed;

/**
* Returns true if the container can return an entry for the given identifier.
* Returns false otherwise.
*
* `has($id)` returning true does not mean that `get($id)` will not throw an exception.
* It does however mean that `get($id)` will not throw a `NotFoundExceptionInterface`.
*
**
* @param string $id Identifier of the entry to look for.
*
* @return bool
Expand Down

0 comments on commit aa19abc

Please sign in to comment.