Pouch
class Pouch implements ContainerInterface, Countable
Traits
Properties
static string | $cacheStoreKey | Key of the singleton holding the cache handler. | from CacheTrait |
protected bool | $isFactory | Whether a bind will be a factory. | from FactoryTrait |
protected array | $factoryArgs | Holds the data to be passed as args to the factory. | from FactoryTrait |
protected bool | $named | Whether this item should be retrievable by only its name and without a typehint. | |
static protected array | $singletons | Store all singletons. | |
protected Item[] | $replaceables | Store all the data that can be replaced. |
Methods
Alias for bind.
Allows the use of isset() to determine if something exists in the container.
Allows the use of unset() to remove key a key from the container.
Bind a new key or fetch an existing one if no argument is provided.
Set factory for upcoming bind or create a factory callable.
Bootstrap pouch.
Register one or more namespaces for automatic resolution.
Resolve specific key from the replaceables array.
See if specific key exists in our replaceables.
Returns the hook manager.
String representation of a pouch instance.
Count elements of the container.
Throws an exception if the callable argument is not a callable.
Details
in AliasTrait at line 17
AliasTrait
register(string|array $keyOrData, callable|null $data = null)
Alias for bind.
in AliasTrait at line 30
AliasTrait
set(string|array $keyOrData, callable|null $data = null)
Alias for bind.
in AliasTrait at line 42
mixed
resolve(string $key)
Fetches from container with getContent.
in AliasTrait at line 54
bool
contains(string $key)
Alias for has.
in AliasTrait at line 66
mixed
__get(string $key)
Allow retrieving container values via magic properties.
in AliasTrait at line 78
bool
__isset(string $key)
Allows the use of isset() to determine if something exists in the container.
in AliasTrait at line 90
void
__unset(string $key)
Allows the use of unset() to remove key a key from the container.
in AliasTrait at line 104
mixed
__call(string $key, array $data)
Bind a new key or fetch an existing one if no argument is provided.
. If an argument is provided: Only the first one will be considered and it must be a callable.
in CacheTrait at line 31
protected mixed
cache(string $key, Closure $value)
Helper to retrieve data from cache store.
in FactoryTrait at line 33
$this|Item
factory(bool|Closure|Item $isFactoryOrCallableOrItem = true)
Set factory for upcoming bind or create a factory callable.
in FactoryTrait at line 54
FactoryTrait
withArgs(mixed ...$args)
Set the args to construct the factory with.
in FactoryTrait at line 68
protected FactoryTrait
setFactoryArgs(string $key)
Set the arguments during fetch-time.
at line 73
static void
bootstrap(string $rootDir, CacheInterface|null $cacheStore = null, string|null $startPath = null)
Bootstrap pouch.
at line 102
static mixed
singleton(string $key, Closure $data = null)
Insert or return a singleton instance from our container.
at line 127
Pouch
bind(string|array $keyOrData, callable|Item|null $data = null)
Bind a new element to the replaceables.
at line 165
Pouch
alias(string $key, string $referenceKey)
Create an alias key for an existing key.
at line 183
Pouch
registerNamespaces(string|string[] $namespaces)
Register one or more namespaces for automatic resolution.
at line 209
mixed
get(string $key)
Resolve specific key from the replaceables array.
at line 236
Closure
raw(string $key)
Resolve a key without invoking it if it happens to be a factory.
at line 256
Item
item(string $key)
Returns the item instance for the key.
at line 290
bool
has(string $key)
See if specific key exists in our replaceables.
at line 302
Pouch
remove(string $key)
Remove key from the container.
at line 316
HookManager
getHookManager()
Returns the hook manager.
at line 326
string
__toString()
String representation of a pouch instance.
at line 341
int
count()
Count elements of the container.
at line 353
protected void
validateData(mixed $data)
Throws an exception if the callable argument is not a callable.