atelierspierrot/service-container

View on GitHub
phpdoc/ServiceContainer/ApiServiceContainer.html

Summary

Maintainability
Test Coverage
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta name="robots" content="index, follow, all" />
    <title>ServiceContainer\ApiServiceContainer | Service Container</title>

            <link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css">
        <link rel="stylesheet" type="text/css" href="../css/bootstrap-theme.min.css">
        <link rel="stylesheet" type="text/css" href="../css/sami.css">
        <script src="../js/jquery-1.11.1.min.js"></script>
        <script src="../js/bootstrap.min.js"></script>
        <script src="../js/typeahead.min.js"></script>
        <script src="../sami.js"></script>
        <meta name="MobileOptimized" content="width">
        <meta name="HandheldFriendly" content="true">
        <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1">
    
    
    </head>

    <body id="class" data-name="class:ServiceContainer_ApiServiceContainer" data-root-path="../">
            <div id="content">
        <div id="left-column">
                <div id="control-panel">
                <form id="search-form" action="../search.html" method="GET">
            <span class="glyphicon glyphicon-search"></span>
            <input name="search"
                   class="typeahead form-control"
                   type="search"
                   placeholder="Search">
        </form>
    </div>

                <div id="api-tree"></div>

        </div>
        <div id="right-column">
                <nav id="site-nav" class="navbar navbar-default" role="navigation">
        <div class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-elements">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="../index.html">Service Container</a>
            </div>
            <div class="collapse navbar-collapse" id="navbar-elements">
                <ul class="nav navbar-nav">
                    <li><a href="../classes.html">Classes</a></li>
                                            <li><a href="../namespaces.html">Namespaces</a></li>
                                        <li><a href="../interfaces.html">Interfaces</a></li>
                    <li><a href="../traits.html">Traits</a></li>
                    <li><a href="../doc-index.html">Index</a></li>
                    <li><a href="../search.html">Search</a></li>
                </ul>
            </div>
        </div>
    </nav>

                        <div class="namespace-breadcrumbs">
            <ol class="breadcrumb">
                <li><span class="label label-default">class</span></li>
                                                            <li><a href="../ServiceContainer.html">ServiceContainer</a></li>
    
                <li>ApiServiceContainer</li>
            </ol>
        </div>
                <div id="page-content">
                
    <div class="page-header">
        <h1>ApiServiceContainer</h1>
    </div>

    <p>    class
    <strong>ApiServiceContainer</strong>        extends <a href="../ServiceContainer/ServiceContainer.html"><abbr title="ServiceContainer\ServiceContainer">ServiceContainer</abbr></a>
</p>

            <div class="description">
            <p>A service container with constructors based on an API declaration and validation</p>                    </div>
    
            <h2>Traits</h2>

        
    <div class="container-fluid underlined">
                    <div class="row">
                <div class="col-md-6">
                                            <abbr title="Patterns\Traits\ApiManagerTrait">Patterns\Traits\ApiManagerTrait</abbr>
                                    </div>
                <div class="col-md-6">
                    

                </div>
            </div>
                    <div class="row">
                <div class="col-md-6">
                                            <abbr title="Patterns\Traits\SingletonTrait">Patterns\Traits\SingletonTrait</abbr>
                                    </div>
                <div class="col-md-6">
                    

                </div>
            </div>
            </div>
    
    
    
            <h2>Methods</h2>

            <div class="container-fluid underlined">
                    <div class="row">
                <div class="col-md-2 type">
                    
    <abbr title="ServiceContainer\$this">$this</abbr>
                </div>
                <div class="col-md-8 type">
                    <a href="#method_init">init</a>(
    array $initial_services = array(), 
    array $services_providers = array(), 
    array $services_protected = array())
                                            <p>Initialize the service container system</p>                </div>
                <div class="col-md-2"><small>from&nbsp;
    <a href="../ServiceContainer/ServiceContainer.html#method_init"><abbr title="ServiceContainer\ServiceContainer">ServiceContainer</abbr></a></small></div>
            </div>
                    <div class="row">
                <div class="col-md-2 type">
                    
    mixed
                </div>
                <div class="col-md-8 type">
                    <a href="#method_setProvider">setProvider</a>(
    string $name, 
    array $provider)
                                            <p>Define a service constructor like <code>array( name , callback , protected )</code> or a closure</p>                </div>
                <div class="col-md-2"><small>from&nbsp;
    <a href="../ServiceContainer/ServiceContainer.html#method_setProvider"><abbr title="ServiceContainer\ServiceContainer">ServiceContainer</abbr></a></small></div>
            </div>
                    <div class="row">
                <div class="col-md-2 type">
                    
    mixed
                </div>
                <div class="col-md-8 type">
                    <a href="#method_getProvider">getProvider</a>(
    string $name)
                                            <p>Get a service constructor if it exists</p>                </div>
                <div class="col-md-2"><small>from&nbsp;
    <a href="../ServiceContainer/ServiceContainer.html#method_getProvider"><abbr title="ServiceContainer\ServiceContainer">ServiceContainer</abbr></a></small></div>
            </div>
                    <div class="row">
                <div class="col-md-2 type">
                    
    bool
                </div>
                <div class="col-md-8 type">
                    <a href="#method_hasProvider">hasProvider</a>(
    string $name)
                                            <p>Test if a constructor exists for a service</p>                </div>
                <div class="col-md-2"><small>from&nbsp;
    <a href="../ServiceContainer/ServiceContainer.html#method_hasProvider"><abbr title="ServiceContainer\ServiceContainer">ServiceContainer</abbr></a></small></div>
            </div>
                    <div class="row">
                <div class="col-md-2 type">
                    
    <abbr title="ServiceContainer\$this">$this</abbr>
                </div>
                <div class="col-md-8 type">
                    <a href="#method_setProtected">setProtected</a>(
    string $name)
                                            <p>Define a service as protected</p>                </div>
                <div class="col-md-2"><small>from&nbsp;
    <a href="../ServiceContainer/ServiceContainer.html#method_setProtected"><abbr title="ServiceContainer\ServiceContainer">ServiceContainer</abbr></a></small></div>
            </div>
                    <div class="row">
                <div class="col-md-2 type">
                    
    bool
                </div>
                <div class="col-md-8 type">
                    <a href="#method_isProtected">isProtected</a>(
    string $name)
                                            <p>Test if a service is protected</p>                </div>
                <div class="col-md-2"><small>from&nbsp;
    <a href="../ServiceContainer/ServiceContainer.html#method_isProtected"><abbr title="ServiceContainer\ServiceContainer">ServiceContainer</abbr></a></small></div>
            </div>
                    <div class="row">
                <div class="col-md-2 type">
                    
    mixed
                </div>
                <div class="col-md-8 type">
                    <a href="#method_setService">setService</a>(
    string $name, 
    object|callable $callback, 
    bool $protected = false)
                                            <p>Register a new service called <code>$name</code> declared as NOT protected by default</p>                </div>
                <div class="col-md-2"><small>from&nbsp;
    <a href="../ServiceContainer/ServiceContainer.html#method_setService"><abbr title="ServiceContainer\ServiceContainer">ServiceContainer</abbr></a></small></div>
            </div>
                    <div class="row">
                <div class="col-md-2 type">
                    
    mixed
                </div>
                <div class="col-md-8 type">
                    <a href="#method_getService">getService</a>(
    string $name, 
    array $arguments = array(), 
    int $failure = self::FAIL_WITH_ERROR)
                                            <p>Get a service called <code>$name</code> throwing an error by default if it does not exist yet and can not be created</p>                </div>
                <div class="col-md-2"><small>from&nbsp;
    <a href="../ServiceContainer/ServiceContainer.html#method_getService"><abbr title="ServiceContainer\ServiceContainer">ServiceContainer</abbr></a></small></div>
            </div>
                    <div class="row">
                <div class="col-md-2 type">
                    
    mixed
                </div>
                <div class="col-md-8 type">
                    <a href="#method_hasService">hasService</a>(
    string $name)
                                            <p>Test if a service exists in the container</p>                </div>
                <div class="col-md-2"><small>from&nbsp;
    <a href="../ServiceContainer/ServiceContainer.html#method_hasService"><abbr title="ServiceContainer\ServiceContainer">ServiceContainer</abbr></a></small></div>
            </div>
                    <div class="row">
                <div class="col-md-2 type">
                    
    mixed
                </div>
                <div class="col-md-8 type">
                    <a href="#method_unsetService">unsetService</a>(
    string $name)
                                            <p>Unset a service if it is not protected</p>                </div>
                <div class="col-md-2"><small>from&nbsp;
    <a href="../ServiceContainer/ServiceContainer.html#method_unsetService"><abbr title="ServiceContainer\ServiceContainer">ServiceContainer</abbr></a></small></div>
            </div>
                    <div class="row">
                <div class="col-md-2 type">
                    static&nbsp;
    object
                </div>
                <div class="col-md-8 type">
                    <a href="#method_apiFactory">apiFactory</a>(
    string $name, 
    string $class, 
    array $arguments = array())
                                            <p>Usage:</p>                </div>
                <div class="col-md-2"></div>
            </div>
            </div>


        <h2>Details</h2>

            <div id="method-details">
                    <div class="method-item">
                    <h3 id="method_init">
        <div class="location">in 
    <a href="../ServiceContainer/ServiceContainer.html#method_init"><abbr title="ServiceContainer\ServiceContainer">ServiceContainer</abbr></a> at line 75</div>
        <code>                    
    <abbr title="ServiceContainer\$this">$this</abbr>
    <strong>init</strong>(
    array $initial_services = array(), 
    array $services_providers = array(), 
    array $services_protected = array())</code>
    </h3>
    <div class="details">
                    <div class="method-description">
                                    <p>Initialize the service container system</p>                                </div>
                <div class="tags">
                            <h4>Parameters</h4>

                    <table class="table table-condensed">
                    <tr>
                <td>
    array</td>
                <td>$initial_services</td>
                <td>
</td>
            </tr>
                    <tr>
                <td>
    array</td>
                <td>$services_providers</td>
                <td>
</td>
            </tr>
                    <tr>
                <td>
    array</td>
                <td>$services_protected</td>
                <td>
</td>
            </tr>
            </table>

            
                            <h4>Return Value</h4>

                    <table class="table table-condensed">
        <tr>
            <td>
    <abbr title="ServiceContainer\$this">$this</abbr></td>
            <td>
</td>
        </tr>
    </table>

            
            
                    </div>
    </div>

            </div>
                    <div class="method-item">
                    <h3 id="method_setProvider">
        <div class="location">in 
    <a href="../ServiceContainer/ServiceContainer.html#method_setProvider"><abbr title="ServiceContainer\ServiceContainer">ServiceContainer</abbr></a> at line 113</div>
        <code>                    
    mixed
    <strong>setProvider</strong>(
    string $name, 
    array $provider)</code>
    </h3>
    <div class="details">
                    <div class="method-description">
                                    <p>Define a service constructor like <code>array( name , callback , protected )</code> or a closure</p>                                </div>
                <div class="tags">
                            <h4>Parameters</h4>

                    <table class="table table-condensed">
                    <tr>
                <td>
    string</td>
                <td>$name</td>
                <td>
</td>
            </tr>
                    <tr>
                <td>
    array</td>
                <td>$provider</td>
                <td>A service array constructor like <code>array( name , callback , protected )</code>
         callable    $provider A callback as a closure that must return the service object: function ($name, $arguments) {}
         ServiceProviderInterface    $provider A <code>\ServiceContainer\ServiceProviderInterface</code> instance</td>
            </tr>
            </table>

            
                            <h4>Return Value</h4>

                    <table class="table table-condensed">
        <tr>
            <td>
    mixed</td>
            <td>
</td>
        </tr>
    </table>

            
            
                    </div>
    </div>

            </div>
                    <div class="method-item">
                    <h3 id="method_getProvider">
        <div class="location">in 
    <a href="../ServiceContainer/ServiceContainer.html#method_getProvider"><abbr title="ServiceContainer\ServiceContainer">ServiceContainer</abbr></a> at line 128</div>
        <code>                    
    mixed
    <strong>getProvider</strong>(
    string $name)</code>
    </h3>
    <div class="details">
                    <div class="method-description">
                                    <p>Get a service constructor if it exists</p>                                </div>
                <div class="tags">
                            <h4>Parameters</h4>

                    <table class="table table-condensed">
                    <tr>
                <td>
    string</td>
                <td>$name</td>
                <td>
</td>
            </tr>
            </table>

            
                            <h4>Return Value</h4>

                    <table class="table table-condensed">
        <tr>
            <td>
    mixed</td>
            <td>
</td>
        </tr>
    </table>

            
            
                    </div>
    </div>

            </div>
                    <div class="method-item">
                    <h3 id="method_hasProvider">
        <div class="location">in 
    <a href="../ServiceContainer/ServiceContainer.html#method_hasProvider"><abbr title="ServiceContainer\ServiceContainer">ServiceContainer</abbr></a> at line 140</div>
        <code>                    
    bool
    <strong>hasProvider</strong>(
    string $name)</code>
    </h3>
    <div class="details">
                    <div class="method-description">
                                    <p>Test if a constructor exists for a service</p>                                </div>
                <div class="tags">
                            <h4>Parameters</h4>

                    <table class="table table-condensed">
                    <tr>
                <td>
    string</td>
                <td>$name</td>
                <td>
</td>
            </tr>
            </table>

            
                            <h4>Return Value</h4>

                    <table class="table table-condensed">
        <tr>
            <td>
    bool</td>
            <td>
</td>
        </tr>
    </table>

            
            
                    </div>
    </div>

            </div>
                    <div class="method-item">
                    <h3 id="method_setProtected">
        <div class="location">in 
    <a href="../ServiceContainer/ServiceContainer.html#method_setProtected"><abbr title="ServiceContainer\ServiceContainer">ServiceContainer</abbr></a> at line 151</div>
        <code>                    
    <abbr title="ServiceContainer\$this">$this</abbr>
    <strong>setProtected</strong>(
    string $name)</code>
    </h3>
    <div class="details">
                    <div class="method-description">
                                    <p>Define a service as protected</p>                                </div>
                <div class="tags">
                            <h4>Parameters</h4>

                    <table class="table table-condensed">
                    <tr>
                <td>
    string</td>
                <td>$name</td>
                <td>
</td>
            </tr>
            </table>

            
                            <h4>Return Value</h4>

                    <table class="table table-condensed">
        <tr>
            <td>
    <abbr title="ServiceContainer\$this">$this</abbr></td>
            <td>
</td>
        </tr>
    </table>

            
            
                    </div>
    </div>

            </div>
                    <div class="method-item">
                    <h3 id="method_isProtected">
        <div class="location">in 
    <a href="../ServiceContainer/ServiceContainer.html#method_isProtected"><abbr title="ServiceContainer\ServiceContainer">ServiceContainer</abbr></a> at line 163</div>
        <code>                    
    bool
    <strong>isProtected</strong>(
    string $name)</code>
    </h3>
    <div class="details">
                    <div class="method-description">
                                    <p>Test if a service is protected</p>                                </div>
                <div class="tags">
                            <h4>Parameters</h4>

                    <table class="table table-condensed">
                    <tr>
                <td>
    string</td>
                <td>$name</td>
                <td>
</td>
            </tr>
            </table>

            
                            <h4>Return Value</h4>

                    <table class="table table-condensed">
        <tr>
            <td>
    bool</td>
            <td>
</td>
        </tr>
    </table>

            
            
                    </div>
    </div>

            </div>
                    <div class="method-item">
                    <h3 id="method_setService">
        <div class="location">in 
    <a href="../ServiceContainer/ServiceContainer.html#method_setService"><abbr title="ServiceContainer\ServiceContainer">ServiceContainer</abbr></a> at line 180</div>
        <code>                    
    mixed
    <strong>setService</strong>(
    string $name, 
    object|callable $callback, 
    bool $protected = false)</code>
    </h3>
    <div class="details">
                    <div class="method-description">
                                    <p>Register a new service called <code>$name</code> declared as NOT protected by default</p>                                </div>
                <div class="tags">
                            <h4>Parameters</h4>

                    <table class="table table-condensed">
                    <tr>
                <td>
    string</td>
                <td>$name</td>
                <td>
</td>
            </tr>
                    <tr>
                <td>
    object|callable</td>
                <td>$callback</td>
                <td>
</td>
            </tr>
                    <tr>
                <td>
    bool</td>
                <td>$protected</td>
                <td>
</td>
            </tr>
            </table>

            
                            <h4>Return Value</h4>

                    <table class="table table-condensed">
        <tr>
            <td>
    mixed</td>
            <td>
</td>
        </tr>
    </table>

            
                            <h4>Exceptions</h4>

                    <table class="table table-condensed">
                    <tr>
                <td><a target="_blank" href="http://php.net/ErrorException"><abbr title="ErrorException">ErrorException</abbr></a></td>
                <td>
</td>
            </tr>
            </table>

            
                    </div>
    </div>

            </div>
                    <div class="method-item">
                    <h3 id="method_getService">
        <div class="location">in 
    <a href="../ServiceContainer/ServiceContainer.html#method_getService"><abbr title="ServiceContainer\ServiceContainer">ServiceContainer</abbr></a> at line 205</div>
        <code>                    
    mixed
    <strong>getService</strong>(
    string $name, 
    array $arguments = array(), 
    int $failure = self::FAIL_WITH_ERROR)</code>
    </h3>
    <div class="details">
                    <div class="method-description">
                                    <p>Get a service called <code>$name</code> throwing an error by default if it does not exist yet and can not be created</p>                                </div>
                <div class="tags">
                            <h4>Parameters</h4>

                    <table class="table table-condensed">
                    <tr>
                <td>
    string</td>
                <td>$name</td>
                <td>
</td>
            </tr>
                    <tr>
                <td>
    array</td>
                <td>$arguments</td>
                <td>
</td>
            </tr>
                    <tr>
                <td>
    int</td>
                <td>$failure</td>
                <td>
</td>
            </tr>
            </table>

            
                            <h4>Return Value</h4>

                    <table class="table table-condensed">
        <tr>
            <td>
    mixed</td>
            <td>
</td>
        </tr>
    </table>

            
                            <h4>Exceptions</h4>

                    <table class="table table-condensed">
                    <tr>
                <td><a target="_blank" href="http://php.net/ErrorException"><abbr title="ErrorException">ErrorException</abbr></a></td>
                <td>
</td>
            </tr>
            </table>

            
                    </div>
    </div>

            </div>
                    <div class="method-item">
                    <h3 id="method_hasService">
        <div class="location">in 
    <a href="../ServiceContainer/ServiceContainer.html#method_hasService"><abbr title="ServiceContainer\ServiceContainer">ServiceContainer</abbr></a> at line 229</div>
        <code>                    
    mixed
    <strong>hasService</strong>(
    string $name)</code>
    </h3>
    <div class="details">
                    <div class="method-description">
                                    <p>Test if a service exists in the container</p>                                </div>
                <div class="tags">
                            <h4>Parameters</h4>

                    <table class="table table-condensed">
                    <tr>
                <td>
    string</td>
                <td>$name</td>
                <td>
</td>
            </tr>
            </table>

            
                            <h4>Return Value</h4>

                    <table class="table table-condensed">
        <tr>
            <td>
    mixed</td>
            <td>
</td>
        </tr>
    </table>

            
            
                    </div>
    </div>

            </div>
                    <div class="method-item">
                    <h3 id="method_unsetService">
        <div class="location">in 
    <a href="../ServiceContainer/ServiceContainer.html#method_unsetService"><abbr title="ServiceContainer\ServiceContainer">ServiceContainer</abbr></a> at line 241</div>
        <code>                    
    mixed
    <strong>unsetService</strong>(
    string $name)</code>
    </h3>
    <div class="details">
                    <div class="method-description">
                                    <p>Unset a service if it is not protected</p>                                </div>
                <div class="tags">
                            <h4>Parameters</h4>

                    <table class="table table-condensed">
                    <tr>
                <td>
    string</td>
                <td>$name</td>
                <td>
</td>
            </tr>
            </table>

            
                            <h4>Return Value</h4>

                    <table class="table table-condensed">
        <tr>
            <td>
    mixed</td>
            <td>
</td>
        </tr>
    </table>

            
                            <h4>Exceptions</h4>

                    <table class="table table-condensed">
                    <tr>
                <td><a target="_blank" href="http://php.net/ErrorException"><abbr title="ErrorException">ErrorException</abbr></a></td>
                <td>
</td>
            </tr>
            </table>

            
                    </div>
    </div>

            </div>
                    <div class="method-item">
                    <h3 id="method_apiFactory">
        <div class="location">at line 56</div>
        <code>        static            
    object
    <strong>apiFactory</strong>(
    string $name, 
    string $class, 
    array $arguments = array())</code>
    </h3>
    <div class="details">
                    <div class="method-description">
                                    <p>Usage:</p>                    <p>self::set($var, self::apiFactory($var, $val));</p>            </div>
                <div class="tags">
                            <h4>Parameters</h4>

                    <table class="table table-condensed">
                    <tr>
                <td>
    string</td>
                <td>$name</td>
                <td>
</td>
            </tr>
                    <tr>
                <td>
    string</td>
                <td>$class</td>
                <td>
</td>
            </tr>
                    <tr>
                <td>
    array</td>
                <td>$arguments</td>
                <td>
</td>
            </tr>
            </table>

            
                            <h4>Return Value</h4>

                    <table class="table table-condensed">
        <tr>
            <td>
    object</td>
            <td>
</td>
        </tr>
    </table>

            
                            <h4>Exceptions</h4>

                    <table class="table table-condensed">
                    <tr>
                <td><a target="_blank" href="http://php.net/ErrorException"><abbr title="ErrorException">ErrorException</abbr></a></td>
                <td>
</td>
            </tr>
            </table>

            
                    </div>
    </div>

            </div>
            </div>

    
            </div>
                <div id="footer">
        Generated by <a href="http://sami.sensiolabs.org/">Sami, the API Documentation Generator</a>.
    </div>

        </div>
    </div>
    </body>

</html>