Overview

Namespaces

  • Charcoal
    • App
      • Action
      • Config
      • Handler
      • Middleware
      • Module
      • Route
      • Script
      • ServiceProvider
      • Template

Classes

  • Charcoal\App\Action\AbstractAction
  • Charcoal\App\App
  • Charcoal\App\AppConfig
  • Charcoal\App\AppContainer
  • Charcoal\App\Config\CacheConfig
  • Charcoal\App\Config\DatabaseConfig
  • Charcoal\App\Config\FilesystemConfig
  • Charcoal\App\Config\LoggerConfig
  • Charcoal\App\Config\MemcacheCacheConfig
  • Charcoal\App\Config\MemcacheCacheServerConfig
  • Charcoal\App\Handler\AbstractHandler
  • Charcoal\App\Handler\Error
  • Charcoal\App\Handler\HandlerConfig
  • Charcoal\App\Handler\NotAllowed
  • Charcoal\App\Handler\NotFound
  • Charcoal\App\Handler\PhpError
  • Charcoal\App\Handler\Shutdown
  • Charcoal\App\Middleware\CacheMiddleware
  • Charcoal\App\Module\AbstractModule
  • Charcoal\App\Module\ModuleConfig
  • Charcoal\App\Module\ModuleManager
  • Charcoal\App\Route\ActionRoute
  • Charcoal\App\Route\ActionRouteConfig
  • Charcoal\App\Route\RouteConfig
  • Charcoal\App\Route\RouteManager
  • Charcoal\App\Route\ScriptRoute
  • Charcoal\App\Route\ScriptRouteConfig
  • Charcoal\App\Route\TemplateRoute
  • Charcoal\App\Route\TemplateRouteConfig
  • Charcoal\App\Script\AbstractScript
  • Charcoal\App\ServiceProvider\AppServiceProvider
  • Charcoal\App\ServiceProvider\CacheServiceProvider
  • Charcoal\App\ServiceProvider\DatabaseServiceProvider
  • Charcoal\App\ServiceProvider\FilesystemServiceProvider
  • Charcoal\App\ServiceProvider\LoggerServiceProvider
  • Charcoal\App\ServiceProvider\ViewServiceProvider
  • Charcoal\App\Template\AbstractTemplate
  • Charcoal\App\Template\AbstractWidget
  • Charcoal\App\Template\WidgetBuilder

Interfaces

  • Charcoal\App\Action\ActionInterface
  • Charcoal\App\AppAwareInterface
  • Charcoal\App\Handler\HandlerInterface
  • Charcoal\App\Module\ModuleInterface
  • Charcoal\App\Route\RouteInterface
  • Charcoal\App\Script\CronScriptInterface
  • Charcoal\App\Script\ScriptInterface
  • Charcoal\App\Template\TemplateInterface
  • Charcoal\App\Template\WidgetInterface

Traits

  • Charcoal\App\AppAwareTrait
  • Charcoal\App\CallableResolverAwareTrait
  • Charcoal\App\Script\ArgScriptTrait
  • Charcoal\App\Script\CronScriptTrait
  • Charcoal\App\Script\PathScriptTrait
  • Overview
  • Namespace
  • Class
  1: <?php
  2: 
  3: namespace Charcoal\App\Config;
  4: 
  5: use \InvalidArgumentException;
  6: 
  7: use \Charcoal\Config\AbstractConfig;
  8: 
  9: /**
 10:  * Database Config
 11:  */
 12: class DatabaseConfig extends AbstractConfig
 13: {
 14:     /**
 15:      * @var string $type
 16:      */
 17:     private $type;
 18: 
 19:     /**
 20:      * @var string $hostname
 21:      */
 22:     private $hostname;
 23: 
 24:     /**
 25:      * @var string $username
 26:      */
 27:     private $username;
 28: 
 29:     /**
 30:      * @var string $password
 31:      */
 32:     private $password;
 33: 
 34:     /**
 35:      * @var string $database
 36:      */
 37:     private $database;
 38: 
 39:     /**
 40:      * @var boolean $disableUtf8
 41:      */
 42:     private $disableUtf8;
 43: 
 44:     /**
 45:      * @return array
 46:      */
 47:     public function defaults()
 48:     {
 49:         return [
 50:             'type'              => 'mysql',
 51:             'hostname'          => 'localhost',
 52:             'username'          => '',
 53:             'password'          => '',
 54:             'database'          => '',
 55:             'disable_utf8'      => false
 56:         ];
 57:     }
 58: 
 59:     /**
 60:      * @param string $type The database type.
 61:      * @throws InvalidArgumentException If parameter is not a string.
 62:      * @return SourceConfig Chainable
 63:      */
 64:     public function setType($type)
 65:     {
 66:         if (!is_string($type)) {
 67:             throw new InvalidArgumentException(
 68:                 'Source type must be a string.'
 69:             );
 70:         }
 71:         $this->type = $type;
 72:         return $this;
 73:     }
 74: 
 75:     /**
 76:      * @return string
 77:      */
 78:     public function type()
 79:     {
 80:         return $this->type;
 81:     }
 82: 
 83:     /**
 84:      * Set database hostname
 85:      *
 86:      * @param string $hostname The database server hostname.
 87:      * @throws InvalidArgumentException If hostname is not a string.
 88:      * @return DatabaseConfig Chainable
 89:      */
 90:     public function setHostname($hostname)
 91:     {
 92:         if (!is_string($hostname)) {
 93:             throw new InvalidArgumentException(
 94:                 'Hostname must be a string.'
 95:             );
 96:         }
 97:         $this->hostname = $hostname;
 98:         return $this;
 99:     }
100: 
101:     /**
102:      * Get database hostname.
103:      *
104:      * @return string
105:      */
106:     public function hostname()
107:     {
108:         return $this->hostname;
109:     }
110: 
111:     /**
112:      * Set database username
113:      *
114:      * @param string $username The database authentication user.
115:      * @throws InvalidArgumentException If username is not a string.
116:      * @return DatabaseConfig Chainable
117:      */
118:     public function setUsername($username)
119:     {
120:         if (!is_string($username)) {
121:             throw new InvalidArgumentException(
122:                 'Username must be a string.'
123:             );
124:         }
125:         $this->username = $username;
126:         return $this;
127:     }
128: 
129:     /**
130:      * Get username
131:      *
132:      * @return string
133:      */
134:     public function username()
135:     {
136:         return $this->username;
137:     }
138: 
139:     /**
140:      * Set password
141:      *
142:      * @param string $password The database authentication password.
143:      * @throws InvalidArgumentException If password is not a string.
144:      * @return DatabaseConfig Chainable
145:      */
146:     public function setPassword($password)
147:     {
148:         if (!is_string($password)) {
149:             throw new InvalidArgumentException(
150:                 'Password must be a string.'
151:             );
152:         }
153:         $this->password = $password;
154:         return $this;
155:     }
156: 
157:     /**
158:      * Get password
159:      *
160:      * @return string
161:      */
162:     public function password()
163:     {
164:         return $this->password;
165:     }
166: 
167:     /**
168:      * Set database
169:      *
170:      * @param string $database The database name.
171:      * @throws InvalidArgumentException If database is not a string.
172:      * @return DatabaseConfig Chainable
173:      */
174:     public function setDatabase($database)
175:     {
176:         if (!is_string($database)) {
177:             throw new InvalidArgumentException(
178:                 'Database must be a string.'
179:             );
180:         }
181:         $this->database = $database;
182:         return $this;
183:     }
184: 
185:     /**
186:      * Get database
187:      *
188:      * @return string
189:      */
190:     public function database()
191:     {
192:         return $this->database;
193:     }
194: 
195:     /**
196:      * @param boolean $disableUtf8 The "disable utf8" flag.
197:      * @return DatabaseConfig Chainable
198:      */
199:     public function setDisableUtf8($disableUtf8)
200:     {
201:         $this->disableUtf8 = !!$disableUtf8;
202:         return $this;
203:     }
204: 
205:     /**
206:      * @return boolean
207:      */
208:     public function disableUtf8()
209:     {
210:         return $this->disableUtf8;
211:     }
212: }
213: 
API documentation generated by ApiGen