aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2015-05-18 09:30:25 +0200
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2015-05-18 09:30:25 +0200
commit51fcec34e418d5d130cc3f121fb9d390fd983203 (patch)
treec00436769107b4f95a444768512f4d53e24fbc57
parent8b23bdc17eb0974fe7d0a3006f0bdd350814df95 (diff)
downloadRegistry-51fcec34e418d5d130cc3f121fb9d390fd983203.zip
Registry-51fcec34e418d5d130cc3f121fb9d390fd983203.tar.gz
Registry-51fcec34e418d5d130cc3f121fb9d390fd983203.tar.bz2
Move to PSR-1 and PSR-2.
-rw-r--r--Exception.php10
-rw-r--r--Registry.php79
-rw-r--r--Test/Unit/Registry.php39
3 files changed, 61 insertions, 67 deletions
diff --git a/Exception.php b/Exception.php
index 266c26a..3585140 100644
--- a/Exception.php
+++ b/Exception.php
@@ -8,7 +8,7 @@
*
* New BSD License
*
- * Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
+ * 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:
@@ -43,9 +43,9 @@ use Hoa\Core;
*
* Extending the \Hoa\Core\Exception class.
*
- * @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
+ * @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-
-class Exception extends Core\Exception { }
+class Exception extends Core\Exception
+{
+}
diff --git a/Registry.php b/Registry.php
index 0460cae..96fe32d 100644
--- a/Registry.php
+++ b/Registry.php
@@ -8,7 +8,7 @@
*
* New BSD License
*
- * Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
+ * 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:
@@ -43,17 +43,15 @@ use Hoa\Core;
*
* Hold a register of something.
*
- * @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
+ * @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-
-class Registry extends \ArrayObject {
-
+class Registry extends \ArrayObject
+{
/**
* Instance.
*
- * @var \Hoa\Registry object
+ * @var \Hoa\Registry
*/
private static $_instance = null;
@@ -62,15 +60,17 @@ class Registry extends \ArrayObject {
/**
* Private constructor.
*
- * @access public
* @return void
- * @throw \Hoa\Registry\Exception
+ * @throws \Hoa\Registry\Exception
*/
- public function __construct ( ) {
-
+ public function __construct()
+ {
throw new Exception(
'Cannot instance the %s object. Use set, get, remove ' .
- 'and isRegistered static methods instead.', 0, __CLASS__);
+ 'and isRegistered static methods instead.',
+ 0,
+ __CLASS__
+ );
return;
}
@@ -78,13 +78,13 @@ class Registry extends \ArrayObject {
/**
* Get instance of \Hoa\Registry.
*
- * @access protected
* @return object
*/
- protected static function getInstance ( ) {
-
- if(null === static::$_instance)
+ protected static function getInstance()
+ {
+ if (null === static::$_instance) {
static::$_instance = new parent();
+ }
return static::$_instance;
}
@@ -92,13 +92,12 @@ class Registry extends \ArrayObject {
/**
* Set a new registry.
*
- * @access public
* @param mixed $index Index of registry.
* @param mixed $value Value of registry.
* @return void
*/
- public static function set ( $index, $value ) {
-
+ public static function set($index, $value)
+ {
static::getInstance()->offsetSet($index, $value);
return;
@@ -107,18 +106,21 @@ class Registry extends \ArrayObject {
/**
* Get a registry.
*
- * @access public
* @param mixed $index Index of registry.
* @return mixed
- * @throw \Hoa\Registry\Exception
+ * @throws \Hoa\Registry\Exception
*/
- public static function get ( $index ) {
-
+ public static function get($index)
+ {
$registry = static::getInstance();
- if(false === $registry->offsetExists($index))
- throw new Exception('Registry %s does not exist.',
- 1, $index);
+ if (false === $registry->offsetExists($index)) {
+ throw new Exception(
+ 'Registry %s does not exist.',
+ 1,
+ $index
+ );
+ }
return $registry->offsetGet($index);
}
@@ -126,24 +128,22 @@ class Registry extends \ArrayObject {
/**
* Check if an index is registered.
*
- * @access public
* @param mixed $index Index of registry.
* @return bool
*/
- public static function isRegistered ( $index ) {
-
+ public static function isRegistered($index)
+ {
return static::getInstance()->offsetExists($index);
}
/**
* Unset an registry.
*
- * @access public
* @param mixed $index Index of registry.
* @return void
*/
- public static function remove ( $index ) {
-
+ public static function remove($index)
+ {
static::getInstance()->offsetUnset($index);
return;
@@ -155,17 +155,15 @@ class Registry extends \ArrayObject {
*
* hoa://Library/Registry component.
*
- * @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
+ * @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-
-class _Protocol extends Core\Protocol {
-
+class _Protocol extends Core\Protocol
+{
/**
* Component's name.
*
- * @var \Hoa\Core\Protocol string
+ * @var string
*/
protected $_name = 'Registry';
@@ -174,12 +172,11 @@ class _Protocol extends Core\Protocol {
/**
* ID of the component.
*
- * @access public
* @param string $id ID of the component.
* @return mixed
*/
- public function reachId ( $id ) {
-
+ public function reachId($id)
+ {
return Registry::get($id);
}
}
diff --git a/Test/Unit/Registry.php b/Test/Unit/Registry.php
index 672160d..07d208d 100644
--- a/Test/Unit/Registry.php
+++ b/Test/Unit/Registry.php
@@ -8,7 +8,7 @@
*
* New BSD License
*
- * Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
+ * 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:
@@ -36,33 +36,30 @@
namespace Hoa\Registry\Test\Unit;
-use Hoa\Test;
use Hoa\Registry as LUT;
+use Hoa\Test;
/**
* Class \Hoa\Registry\Test\Unit\Registry.
*
* Test suite of the registry.
*
- * @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
+ * @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-
-class Registry extends Test\Unit\Suite {
-
- public function case_no_instance ( ) {
-
+class Registry extends Test\Unit\Suite
+{
+ public function case_no_instance()
+ {
$this
- ->exception(function ( ) {
-
+ ->exception(function () {
new LUT();
})
->isInstanceOf('Hoa\Registry\Exception');
}
- public function case_classic ( ) {
-
+ public function case_classic()
+ {
$this
->given(
$string = $this->realdom->string('a', 'z', 5),
@@ -76,8 +73,8 @@ class Registry extends Test\Unit\Suite {
->isEqualTo($value);
}
- public function case_value_is_an_object ( ) {
-
+ public function case_value_is_an_object()
+ {
$this
->given(
$string = $this->realdom->string('a', 'z', 5),
@@ -93,8 +90,8 @@ class Registry extends Test\Unit\Suite {
->isIdenticalTo($value);
}
- public function case_isRegistered ( ) {
-
+ public function case_isRegistered()
+ {
$this
->given(
$string = $this->realdom->string('a', 'z', 5),
@@ -123,8 +120,8 @@ class Registry extends Test\Unit\Suite {
->isFalse();
}
- public function case_protocol ( ) {
-
+ public function case_protocol()
+ {
$this
->given(
$string = $this->realdom->string('a', 'z', 5),
@@ -138,8 +135,8 @@ class Registry extends Test\Unit\Suite {
->isEqualTo($value);
}
- public function case_value_protocol_and_references ( ) {
-
+ public function case_value_protocol_and_references()
+ {
$this
->given(
$string = $this->realdom->string('a', 'z', 5),