Hoa central
Namespaces | Functions | Variables
Hoa\Core Namespace Reference

Namespaces

 Bin
 
 Consistency
 
 Data
 
 Event
 
 Exception
 
 Parameter
 
 Protocol
 

Functions

static getInstance ()
 
 initialize (Array $parameters=[])
 
 getParameters ()
 
 setProtocol ($path=null, $reach=null)
 
static _define ($name, $value, $case=false)
 
static getProtocol ()
 
static enableExceptionHandler ($enable=true)
 
static enableErrorHandler ($enable=true)
 
static registerShutdownFunction ($class= '', $method= '')
 
static getPHPBinary ()
 
static uuid ()
 
static © ()
 

Variables

you have Consistency php Event php Exception php Parameter php Protocol php Data php SUCCEED FAILED … __hoa_core_fill DS PS CRLF OS_WIN PHP_WINDOWS_VERSION_PLATFORM S_64_BITS S_32_BITS PHP_INT_MIN PHP_FLOAT_MIN PHP_FLOAT_MAX π void _public _protected _private _static _abstract _pure _final _dynamic _concrete _overridable WITH_COMPOSER Composer Autoload ClassLoader cli autoload php suhosin executor
 
you have Consistency php Event php Exception php Parameter php Protocol php Data php SUCCEED FAILED … __hoa_core_fill DS PS CRLF OS_WIN PHP_WINDOWS_VERSION_PLATFORM S_64_BITS S_32_BITS PHP_INT_MIN PHP_FLOAT_MIN PHP_FLOAT_MAX π void _public _protected _private _static _abstract _pure _final _dynamic _concrete _overridable WITH_COMPOSER Composer Autoload ClassLoader cli autoload php suhosin The URL scheme hoa
 
you have Consistency php Event php Exception php Parameter php Protocol php Data php SUCCEED FAILED … __hoa_core_fill DS PS CRLF OS_WIN PHP_WINDOWS_VERSION_PLATFORM S_64_BITS S_32_BITS PHP_INT_MIN PHP_FLOAT_MIN PHP_FLOAT_MAX π void _public _protected _private _static _abstract _pure _final _dynamic _concrete _overridable WITH_COMPOSER Composer Autoload ClassLoader cli autoload php suhosin The URL scheme thanks
 
if(true===function_exists('mb_internal_encoding')) if(true===function_exists('mb_regex_encoding')) return
 

Detailed Description

Hoa

New BSD License

Copyright © 2007-2015, Hoa community. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Function Documentation

static Hoa\Core\_define (   $name,
  $value,
  $case = false 
)
static

Check if a constant is already defined. If the constant is defined, this method returns false. Else this method declares the constant.

Parameters
string$nameThe name of the constant.
string$valueThe value of the constant.
bool$caseTrue set the case-insensitive.
Returns
bool

Definition at line 338 of file Core.php.

339  {
340  if (!defined($name)) {
341  return define($name, $value, $case);
342  }
343 
344  return false;
345  }
static Hoa\Core\enableErrorHandler (   $enable = true)
static

Enable error handler: transform PHP error into .

Parameters
bool$enableEnable.
Returns
mixed

Definition at line 384 of file Core.php.

385  {
386  if (false === $enable) {
387  return restore_error_handler();
388  }
389 
390  return set_error_handler(function ($no, $str, $file = null, $line = null, $ctx = null) {
391  return Exception\Idle::error($no, $str, $file, $line, $ctx);
392  });
393  }

Here is the call graph for this function:

static Hoa\Core\enableExceptionHandler (   $enable = true)
static

Enable exception handler: catch uncaught exception.

Parameters
bool$enableEnable.
Returns
mixed

Definition at line 367 of file Core.php.

368  {
369  if (false === $enable) {
370  return restore_exception_handler();
371  }
372 
373  return set_exception_handler(function ($exception) {
374  return Exception\Idle::uncaught($exception);
375  });
376  }

Here is the call graph for this function:

static Hoa\Core\getInstance ( )
static

Singleton.

Returns

Definition at line 193 of file Core.php.

194  {
195  if (null === static::$_instance) {
196  static::$_instance = new static();
197  }
198 
199  return static::$_instance;
200  }

Here is the caller graph for this function:

Hoa\Core\getParameters ( )

Get parameters.

Returns

Definition at line 266 of file Core.php.

267  {
268  return $this->_parameters;
269  }

Here is the caller graph for this function:

static Hoa\Core\getPHPBinary ( )
static

Get PHP executable.

Returns
string

Definition at line 420 of file Core.php.

421  {
422  if (defined('PHP_BINARY')) {
423  return PHP_BINARY;
424  }
425 
426  if (isset($_SERVER['_'])) {
427  return $_SERVER['_'];
428  }
429 
430  foreach (['', '.exe'] as $extension) {
431  if (file_exists($_ = PHP_BINDIR . DS . 'php' . $extension)) {
432  return realpath($_);
433  }
434  }
435 
436  return null;
437  }

Here is the caller graph for this function:

static Hoa\Core\getProtocol ( )
static

Get protocol's root.

Returns

Definition at line 352 of file Core.php.

353  {
354  if (null === static::$_root) {
355  static::$_root = new Protocol\Root();
356  }
357 
358  return static::$_root;
359  }

Here is the caller graph for this function:

Hoa\Core\initialize ( Array  $parameters = [])

Initialize the core.

Parameters
array$parametersParameters of .
Returns

Definition at line 208 of file Core.php.

209  {
210  $root = dirname(dirname(__DIR__));
211  $cwd =
212  'cli' === PHP_SAPI
213  ? dirname(realpath($_SERVER['argv'][0]))
214  : getcwd();
215  $this->_parameters = new Parameter\Parameter(
216  $this,
217  [
218  'root' => $root,
219  'cwd' => $cwd
220  ],
221  [
222  'root.hoa' => '(:root:)',
223  'root.application' => '(:cwd:h:)',
224  'root.data' => '(:%root.application:h:)' . DS . 'Data' . DS,
225 
226  'protocol.Application' => '(:%root.application:)' . DS,
227  'protocol.Application/Public' => 'Public' . DS,
228  'protocol.Data' => '(:%root.data:)',
229  'protocol.Data/Etc' => 'Etc' . DS,
230  'protocol.Data/Etc/Configuration' => 'Configuration' . DS,
231  'protocol.Data/Etc/Locale' => 'Locale' . DS,
232  'protocol.Data/Library' => 'Library' . DS . 'Hoathis' . DS . ';' .
233  'Library' . DS . 'Hoa' . DS,
234  'protocol.Data/Lost+found' => 'Lost+found' . DS,
235  'protocol.Data/Temporary' => 'Temporary' . DS,
236  'protocol.Data/Variable' => 'Variable' . DS,
237  'protocol.Data/Variable/Cache' => 'Cache' . DS,
238  'protocol.Data/Variable/Database' => 'Database' . DS,
239  'protocol.Data/Variable/Log' => 'Log' . DS,
240  'protocol.Data/Variable/Private' => 'Private' . DS,
241  'protocol.Data/Variable/Run' => 'Run' . DS,
242  'protocol.Data/Variable/Test' => 'Test' . DS,
243  'protocol.Library' => '(:%protocol.Data:)Library' . DS . 'Hoathis' . DS . ';' .
244  '(:%protocol.Data:)Library' . DS . 'Hoa' . DS . ';' .
245  '(:%root.hoa:)' . DS . 'Hoathis' . DS . ';' .
246  '(:%root.hoa:)' . DS . 'Hoa' . DS,
247 
248  'namespace.prefix.*' => '(:%protocol.Data:)Library' . DS . ';(:%root.hoa:)' . DS,
249  'namespace.prefix.Application' => '(:%root.application:h:)' . DS,
250  ]
251  );
252 
253  $this->_parameters->setKeyword('root', $root);
254  $this->_parameters->setKeyword('cwd', $cwd);
255  $this->_parameters->setParameters($parameters);
256  $this->setProtocol();
257 
258  return $this;
259  }
setProtocol($path=null, $reach=null)
Definition: Core.php:278

Here is the call graph for this function:

static Hoa\Core\registerShutdownFunction (   $class = '',
  $method = '' 
)
static

Apply and save a register shutdown function. It may be analogous to a static __destruct, but it allows us to make more that a __destruct method.

Parameters
string$classClass.
string$methodMethod.
Returns
bool

Definition at line 404 of file Core.php.

405  {
406  if (!isset(static::$_rsdf[$class][$method])) {
407  static::$_rsdf[$class][$method] = true;
408 
409  return register_shutdown_function([$class, $method]);
410  }
411 
412  return false;
413  }
Hoa\Core\setProtocol (   $path = null,
  $reach = null 
)

Set protocol according to the current parameter.

Parameters
string$pathPath (e.g. hoa://Data/Temporary).
string$reachReach value.
Returns
void

Definition at line 278 of file Core.php.

279  {
280  $root = static::getProtocol();
281 
282  if (null === $path && null === $reach) {
283  if (!isset($root['Library'])) {
284  static::$_root = null;
285  $root = static::getProtocol();
286  }
287 
288  $protocol = $this->getParameters()->unlinearizeBranche('protocol');
289 
290  foreach ($protocol as $components => $reach) {
291  $parts = explode('/', trim($components, '/'));
292  $last = array_pop($parts);
293  $handle = $root;
294 
295  foreach ($parts as $part) {
296  $handle = $handle[$part];
297  }
298 
299  if ('Library' === $last) {
300  $handle[] = new Protocol\Library($last, $reach);
301  } else {
302  $handle[] = new Protocol\Generic($last, $reach);
303  }
304  }
305 
306  return;
307  }
308 
309  if ('hoa://' === substr($path, 0, 6)) {
310  $path = substr($path, 6);
311  }
312 
313  $path = trim($path, '/');
314  $parts = explode('/', $path);
315  $handle = $root;
316 
317  foreach ($parts as $part) {
318  $handle = $handle[$part];
319  }
320 
321  $handle->setReach($reach);
322  $root->clearCache();
323  $this->getParameters()->setParameter('protocol.' . $path, $reach);
324 
325  return;
326  }
static getProtocol()
Definition: Core.php:352
getParameters()
Definition: Core.php:266

Here is the call graph for this function:

Here is the caller graph for this function:

static Hoa\Core\uuid ( )
static

Generate an Universal Unique Identifier (UUID).

Returns
string

Definition at line 444 of file Core.php.

445  {
446  return sprintf(
447  '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
448  mt_rand(0, 0xffff),
449  mt_rand(0, 0xffff),
450  mt_rand(0, 0xffff),
451  mt_rand(0, 0x0fff) | 0x4000,
452  mt_rand(0, 0x3fff) | 0x8000,
453  mt_rand(0, 0xffff),
454  mt_rand(0, 0xffff),
455  mt_rand(0, 0xffff)
456  );
457  }

Here is the caller graph for this function:

static Hoa\Core\© ( )
static

Return the copyright and license of Hoa.

Returns
string

Definition at line 464 of file Core.php.

465  {
466  return
467  'Copyright © 2007-2015 Ivan Enderlin. All rights reserved.' . "\n" .
468  'New BSD License.';
469  }
470 }
471 
472 }
473 
474 namespace {
475 
479 class_alias('Hoa\Core\Core', 'Hoa\Core');
480 
489 if (!function_exists('_define')) {
490  function _define($name, $value, $case = false)
491  {
492  return Hoa\Core::_define($name, $value, $case);
493  }
494 }
495 
502 if (!function_exists('event')) {
503  function event($eventId)
504  {
505  return Hoa\Core\Event\Event::getEvent($eventId);
506  }
507 }
static getEvent($eventId)
Definition: Event.php:200
static _define($name, $value, $case=false)
Definition: Core.php:338

Variable Documentation

you have Consistency php Event php Exception php Parameter php Protocol php Data php SUCCEED FAILED … __hoa_core_fill DS PS CRLF OS_WIN PHP_WINDOWS_VERSION_PLATFORM S_64_BITS S_32_BITS PHP_INT_MIN PHP_FLOAT_MIN PHP_FLOAT_MAX π void _public _protected _private _static _abstract _pure _final _dynamic _concrete _overridable WITH_COMPOSER Composer Autoload ClassLoader cli autoload php suhosin Hoa::Core\executor

Definition at line 160 of file Core.php.

you have Consistency php Event php Exception php Parameter php Protocol php Data php SUCCEED FAILED … __hoa_core_fill DS PS CRLF OS_WIN PHP_WINDOWS_VERSION_PLATFORM S_64_BITS S_32_BITS PHP_INT_MIN PHP_FLOAT_MIN PHP_FLOAT_MAX π void _public _protected _private _static _abstract _pure _final _dynamic _concrete _overridable WITH_COMPOSER Composer Autoload ClassLoader cli autoload php suhosin The URL scheme Hoa::Core\hoa

Definition at line 160 of file Core.php.

if (true===function_exists('mb_internal_encoding')) if (true===function_exists('mb_regex_encoding')) Hoa::Core\return

Definition at line 181 of file Core.php.

you have Consistency php Event php Exception php Parameter php Protocol php Data php SUCCEED FAILED … __hoa_core_fill DS PS CRLF OS_WIN PHP_WINDOWS_VERSION_PLATFORM S_64_BITS S_32_BITS PHP_INT_MIN PHP_FLOAT_MIN PHP_FLOAT_MAX π void _public _protected _private _static _abstract _pure _final _dynamic _concrete _overridable WITH_COMPOSER Composer Autoload ClassLoader cli autoload php suhosin The URL scheme Hoa::Core\thanks

Definition at line 160 of file Core.php.