47 lines
2.5 KiB
HTML
47 lines
2.5 KiB
HTML
![]() |
<h1 style="background-color:#353b3e; color: #eeeeee;">Tonic</h1>
|
||
|
<pre style="font-family:Monaco, monospace; padding:2em; background-color: #2a2f31; color: #eeeeee;">
|
||
|
<?php
|
||
|
|
||
|
<span style="color: #75A1A4;">namespace</span> Illuminate\Container;
|
||
|
|
||
|
<span style="color: #75A1A4;">use</span> Closure;
|
||
|
<span style="color: #75A1A4;">use</span> ArrayAccess;
|
||
|
|
||
|
<span style="color: #4a5356;">/**
|
||
|
* Theme: Tonic
|
||
|
* Tonic.
|
||
|
*
|
||
|
* Copyright (c) 2014 Dayle Rees
|
||
|
*/</span>
|
||
|
<span style="color: #75A1A4;">class</span> Container <span style="color: #B8CD44;">implements</span> ArrayAccess
|
||
|
{
|
||
|
<span style="color: #4a5356;">/**
|
||
|
* An array of the types that have been resolved.
|
||
|
*
|
||
|
* <span style="color: #67757a;">@var</span> array
|
||
|
*/</span>
|
||
|
<span style="color: #B8CD44;">protected</span> <span style="color: ;">$resolved</span> <span style="color: #75A1A4;">=</span> <span style="color: #B8CD44;">array</span>();
|
||
|
|
||
|
<span style="color: #4a5356;">/**
|
||
|
* Determine if a given type is shared.
|
||
|
*
|
||
|
* <span style="color: #67757a;">@param</span> string $abstract
|
||
|
* <span style="color: #67757a;">@return</span> bool
|
||
|
*/</span>
|
||
|
<span style="color: #B8CD44;">public</span> <span style="color: #75A1A4;">function</span> <span style="color: #FD9F59;">isShared</span>(<span style="color: ;">$abstract</span>)
|
||
|
{
|
||
|
<span style="color: #EF6E44;">if</span> (<span style="color: #B8CD44;">isset</span>(<span style="color: ;">$this</span><span style="color: #EF6E44;">-></span><span style="color: ;">bindings</span>[<span style="color: ;">$abstract</span>][<span style="color: #B8CD44;">'shared'</span>]))
|
||
|
{
|
||
|
<span style="color: ;">$shared</span> <span style="color: #EF6E44;">=</span> <span style="color: ;">$this</span><span style="color: #EF6E44;">-></span><span style="color: ;">bindings</span>[<span style="color: ;">$abstract</span>][<span style="color: #B8CD44;">'shared'</span>];
|
||
|
}
|
||
|
<span style="color: #EF6E44;">else</span>
|
||
|
{
|
||
|
<span style="color: ;">$shared</span> <span style="color: #EF6E44;">=</span> <span style="color: #B8CD44;">false</span>;
|
||
|
}
|
||
|
|
||
|
<span style="color: #EF6E44;">return</span> <span style="color: #B8CD44;">isset</span>(<span style="color: ;">$this</span><span style="color: #EF6E44;">-></span><span style="color: ;">instances</span>[<span style="color: ;">$abstract</span>]) <span style="color: #EF6E44;">||</span> <span style="color: ;">$shared</span> <span style="color: #EF6E44;">===</span> <span style="color: #B8CD44;">true</span>;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
</pre>
|