Overview

Namespaces

  • GAubry
    • ErrorHandler
    • Helpers
    • Logger
    • Shell
  • Himedia
    • Padocc
      • DB
      • Minifier
      • Numbering
      • Properties
      • Task
        • Base
        • Extended
  • None
  • Psr
    • Log

Classes

  • AttributeProperties
  • Deployment
  • DeploymentStatus
  • DIContainer
  • Padocc
  • Task

Interfaces

  • DIContainerInterface
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: namespace Himedia\Padocc;
  4: 
  5: use GAubry\Shell\ShellAdapter;
  6: use Himedia\Padocc\Numbering\NumberingInterface;
  7: use Himedia\Padocc\Properties\PropertiesInterface;
  8: use Psr\Log\LoggerInterface;
  9: 
 10: /**
 11:  * Simple container for depency injection.
 12:  *
 13:  * @author Geoffroy AUBRY <gaubry@hi-media.com>
 14:  */
 15: class DIContainer implements DIContainerInterface
 16: {
 17: 
 18:     /**
 19:      * Logger.
 20:      * @var LoggerInterface
 21:      */
 22:     private $oLogger;
 23: 
 24:     /**
 25:      * Properties.
 26:      *
 27:      * @var PropertiesInterface
 28:      */
 29:     private $oProperties;
 30: 
 31:     /**
 32:      * Adaptateur Shell.
 33:      *
 34:      * @var ShellAdapter
 35:      */
 36:     private $oShell;
 37: 
 38:     /**
 39:      * Adaptateur de numérotation.
 40:      * @var NumberingInterface
 41:      */
 42:     private $oNumbering;
 43: 
 44:     /**
 45:      * @var array
 46:      */
 47:     private $aConfig;
 48: 
 49:     /**
 50:      * Constructeur.
 51:      */
 52:     public function __construct ()
 53:     {
 54:         $this->oLogger     = null;
 55:         $this->oProperties = null;
 56:         $this->oShell      = null;
 57:         $this->oNumbering  = null;
 58:         $this->aConfig     = array();
 59:     }
 60: 
 61:     /**
 62:      * @param LoggerInterface $logger
 63:      * @return self
 64:      */
 65:     public function setLogger(LoggerInterface $logger)
 66:     {
 67:         $this->oLogger = $logger;
 68:         return $this;
 69:     }
 70: 
 71:     /**
 72:      * {@inheritdoc}
 73:      *
 74:      * @throws \RuntimeException if no logger set.
 75:      */
 76:     public function getLogger()
 77:     {
 78:         if ($this->oLogger === null) {
 79:             throw new \RuntimeException('No LoggerInterface instance set!');
 80:         }
 81:         return $this->oLogger;
 82:     }
 83: 
 84:     /**
 85:      * @param PropertiesInterface $propertiesAdapter
 86:      * @return self
 87:      */
 88:     public function setPropertiesAdapter(PropertiesInterface $propertiesAdapter)
 89:     {
 90:         $this->oProperties = $propertiesAdapter;
 91:         return $this;
 92:     }
 93: 
 94:     /**
 95:      * {@inheritdoc}
 96:      *
 97:      * @throws \RuntimeException if no properties instance set.
 98:      */
 99:     public function getPropertiesAdapter()
100:     {
101:         if ($this->oProperties === null) {
102:             throw new \RuntimeException('No PropertiesInterface instance set!');
103:         }
104:         return $this->oProperties;
105:     }
106: 
107:     /**
108:      * @param ShellAdapter $shellAdapter
109:      * @return self
110:      */
111:     public function setShellAdapter(ShellAdapter $shellAdapter)
112:     {
113:         $this->oShell = $shellAdapter;
114:         return $this;
115:     }
116: 
117:     /**
118:      * {@inheritdoc}
119:      *
120:      * @throws \RuntimeException if no Shell adapter set.
121:      */
122:     public function getShellAdapter()
123:     {
124:         if ($this->oShell === null) {
125:             throw new \RuntimeException('No ShellAdapter instance set!');
126:         }
127:         return $this->oShell;
128:     }
129: 
130:     /**
131:      * @param NumberingInterface $numberingAdapter
132:      * @return self
133:      */
134:     public function setNumberingAdapter(NumberingInterface $numberingAdapter)
135:     {
136:         $this->oNumbering = $numberingAdapter;
137:         return $this;
138:     }
139: 
140:     /**
141:      * {@inheritdoc}
142:      *
143:      * @throws \RuntimeException if no Numbering adapter set.
144:      */
145:     public function getNumberingAdapter()
146:     {
147:         if ($this->oNumbering === null) {
148:             throw new \RuntimeException('No NumberingInterface instance set!');
149:         }
150:         return $this->oNumbering;
151:     }
152: 
153:     /**
154:      * @param array $config
155:      * @return self
156:      */
157:     public function setConfig(array $config)
158:     {
159:         $this->aConfig = $config;
160:         return $this;
161:     }
162: 
163:     /**
164:      * {@inheritdoc}
165:      *
166:      * @throws \RuntimeException if no config set.
167:      */
168:     public function getConfig()
169:     {
170:         if ($this->aConfig === array()) {
171:             throw new \RuntimeException('No config array set!');
172:         }
173:         return $this->aConfig;
174:     }
175: }
176: 
Platform for Automatized Deployments with pOwerful Concise Configuration API documentation generated by ApiGen 2.8.0