Skip to content

Commit

Permalink
reflection for ease and confusion
Browse files Browse the repository at this point in the history
  • Loading branch information
henderjon committed Jul 6, 2016
1 parent 301bd8e commit 33d612c
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 37 deletions.
6 changes: 3 additions & 3 deletions src/DeferredInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ interface DeferredInterface extends RegistryInterface {
* @param string $key The key of the value to retrieve
* @return mixed
*/
function get($key);
public function get($key);

/**
* Method to retrieve the value stored at key via another invocation.
* @param string $key The key of the value to retrieve
* @param array $args The args to pass the callable
* @return mixed
*/
function getNew($key, array $args = []);
public function getNew($key, array $args = []);

}
}
10 changes: 5 additions & 5 deletions src/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@ class Filter {

protected $map = [];

function __construct(array $map){
public function __construct(array $map){
foreach($map as $k => $v){
$this->map[$k] = $v;
}
}

function get($name){
public function get($name){
if(!isset($this->map[$name])){
return null;
}
return $this->map[$name];
}

function getFiltered($name, callable $callback = null){
public function getFiltered($name, callable $callback = null){
$value = $this->get($name);
if($value != null && $callback){
return call_user_func($callback, $value, $name);
}
return $value;
}

function getAll(){
public function getAll(){
return $this->map;
}

function getAllFiltered(callable $callback = null){
public function getAllFiltered(callable $callback = null){
$values = $this->getAll();
if($callback){
array_walk_recursive($values, $callback);
Expand Down
2 changes: 1 addition & 1 deletion src/Reference.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Reference extends Registry implements RegistryInterface {
* @param array &$map The array to reference
* @return
*/
function __construct( &$map = null ) {
public function __construct( &$map = null ) {
if( $map === null ) {
$map = array();
}
Expand Down
6 changes: 3 additions & 3 deletions src/RegistryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ interface RegistryInterface {
* @param mixed $value The value to store
* @return
*/
function set($key, $value);
public function set($key, $value);

/**
* Method to retrieve the value stored at key
* @param scalar $key The key of the value to retrieve
* @return mixed
*/
function get($key);
public function get($key);

}
}
6 changes: 3 additions & 3 deletions src/ServiceLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
*/
class ServiceLoader {

function loadServices($path){
public function loadServices($path){

return (new ObjectLoader)->loadObject(new Di, $path);

}

function loadDi($path){
public function loadDi($path){
return $this->loadServices($path);
}

}
}
12 changes: 6 additions & 6 deletions src/Set.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ class Set implements SetInterface, \Countable, \IteratorAggregate {
* unshift values to our list
* @param mixed $value
*/
function lpush($value){
public function lpush($value){
array_unshift($this->map, $value);
}

/**
* push values to our list
* @param mixed $value
*/
function rpush($value){
public function rpush($value){
// array_push
$this->map[] = $value;
}
Expand All @@ -35,7 +35,7 @@ function rpush($value){
* shift values off our list
* @return mixed
*/
function lpop(){
public function lpop(){
if($this->count() <= 0) return null;
return array_shift($this->map);
}
Expand All @@ -44,7 +44,7 @@ function lpop(){
* pop values off our array
* @return mixed
*/
function rpop(){
public function rpop(){
if($this->count() <= 0) return null;
return array_pop($this->map);
}
Expand All @@ -53,15 +53,15 @@ function rpop(){
* \Countable -- how big is our list
* @return int
*/
function count(){
public function count(){
return count($this->map);
}

/**
* spin off an iterator for our list
* @return \ArrayIterator
*/
function getIterator(){
public function getIterator(){
return new \ArrayIterator($this->map);
}

Expand Down
12 changes: 6 additions & 6 deletions src/SetInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,30 @@ interface SetInterface {
* unshift values to our list
* @param mixed $value
*/
function lpush($value);
public function lpush($value);

/**
* push values to our list
* @param mixed $value
*/
function rpush($value);
public function rpush($value);

/**
* shift values off our list
* @return mixed
*/
function lpop();
public function lpop();

/**
* pop values off our array
* @return mixed
*/
function rpop();
public function rpop();

/**
* \Countable -- how big is our list
* @return int
*/
function count();
public function count();

}
}
10 changes: 0 additions & 10 deletions tests/PHPUnit/ServiceLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,4 @@ function test_demoClass1(){
$this->assertEquals(1, $O->var);
}

/**
* @expectedException \Exception
*/
// function test_demoClass2(){
// $path = __DIR__ . "/nothelpers";
// $di = (new \Chevron\Containers\ServiceLoader)->loadDi($path);

// $di->set("error", 404);
// }

}

0 comments on commit 33d612c

Please sign in to comment.