Skip to content
This repository has been archived by the owner on Sep 19, 2018. It is now read-only.

Commit

Permalink
Improve code organization and docblock.
Browse files Browse the repository at this point in the history
Signed-off-by: crynobone <crynobone@gmail.com>
  • Loading branch information
crynobone committed Jun 15, 2013
1 parent abb0a84 commit c4a1657
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 33 deletions.
32 changes: 20 additions & 12 deletions src/Orchestra/Resources/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Container implements ArrayAccess {
* @param string $name
* @param mixed $attributes
* @return void
* @throws \InvalidArgumentException
*/
public function __construct($name, $attributes)
{
Expand Down Expand Up @@ -59,12 +60,13 @@ public function __construct($name, $attributes)
}

/**
* Map a child resource attributes
* Map a child resource attributes.
*
* @access public
* @param string $name
* @param string $uses
* @param string $name
* @param string $uses
* @return self
* @throws \InvalidArgumentException
*/
public function route($name, $uses)
{
Expand All @@ -79,11 +81,12 @@ public function route($name, $uses)
}

/**
* Set visibility state based on parameter
* Set visibility state based on parameter.
*
* @access public
* @param boolean $value
* @return self
* @throws \InvalidArgumentException
*/
public function visibility($value)
{
Expand All @@ -93,11 +96,12 @@ public function visibility($value)
}

$this->attributes['visible'] = $value;

return $this;
}

/**
* Set visibility state to show
* Set visibility state to show.
*
* @access public
* @return self
Expand All @@ -108,7 +112,7 @@ public function show()
}

/**
* Set visibility state to hidden
* Set visibility state to hidden.
*
* @access public
* @return self
Expand Down Expand Up @@ -150,8 +154,9 @@ public function __call($method, $parameters)
/**
* Determine if a given offset exists.
*
* @param string $key
* @return bool
* @access public
* @param string $key
* @return boolean
*/
public function offsetExists($key)
{
Expand All @@ -161,7 +166,8 @@ public function offsetExists($key)
/**
* Get the value at a given offset.
*
* @param string $key
* @access public
* @param string $key
* @return mixed
*/
public function offsetGet($key)
Expand All @@ -172,8 +178,9 @@ public function offsetGet($key)
/**
* Set the value at a given offset.
*
* @param string $key
* @param mixed $value
* @access public
* @param string $key
* @param mixed $value
* @return void
*/
public function offsetSet($key, $value)
Expand All @@ -184,7 +191,8 @@ public function offsetSet($key, $value)
/**
* Unset the value at a given offset.
*
* @param string $key
* @access public
* @param string $key
* @return void
*/
public function offsetUnset($key)
Expand Down
18 changes: 10 additions & 8 deletions src/Orchestra/Resources/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ class Dispatcher {
/**
* Application instance.
*
* @var Illuminate\Foundation\Application
* @var \Illuminate\Foundation\Application
*/
protected $app = null;

/**
* Router instance.
*
* @var Illuminate\Routing\Router
* @var \Illuminate\Routing\Router
*/
protected $router = null;

/**
* Request instance.
*
* @var Illuminate\Http\Request
* @var \Illuminate\Http\Request
*/
protected $request = null;

/**
* Construct a new Resources instance.
*
* @access public
* @param Illuminate\Foundation\Application $app
* @param Illuminate\Routing\Router $router
* @param Illuminate\Http\Request $request
* @param \Illuminate\Foundation\Application $app
* @param \Illuminate\Routing\Router $router
* @param \Illuminate\Http\Request $request
* @return void
*/
public function __construct($app, Router $router, Request $request)
Expand All @@ -51,7 +51,7 @@ public function __construct($app, Router $router, Request $request)
* @param array $driver
* @param string $name
* @param array $parameters
* @return void
* @return mixed
*/
public function call($driver, $name = null, $parameters)
{
Expand Down Expand Up @@ -155,10 +155,11 @@ protected function findRoutableAttributes($type = 'restful', $nested = array(),
$action = (count($parameters) > 0 ? array_shift($parameters) : 'index');
$action = Str::camel("{$verb}_{$action}");
break;

case 'resource' :
$action = $this->findResourceRoutable($verb, $parameters, $nested);

break;

default :
throw new InvalidArgumentException("Type [{$type}] not implemented.");
}
Expand Down Expand Up @@ -203,6 +204,7 @@ protected function findResourceRoutable($verb, $parameters = array(), $nested =
$action = 'store';
break;
case 'put' :
# passthru;
case 'patch' :
$action = 'update';
break;
Expand Down
20 changes: 11 additions & 9 deletions src/Orchestra/Resources/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ class Environment {
/**
* Application instance.
*
* @var Illuminate\Foundation\Application
* @var \Illuminate\Foundation\Application
*/
protected $app = null;

/**
* Dispatcher instance.
*
* @var Orchestra\Resources\Dispatcher
* @var \Orchestra\Resources\Dispatcher
*/
protected $dispatcher = null;

/**
* Response instance.
*
* @var Orchestra\Resources\Response
* @var \Orchestra\Resources\Response
*/
protected $response = null;

Expand All @@ -36,7 +36,9 @@ class Environment {
* Construct a new Resources instance.
*
* @access public
* @param Illuminate\Foundation\Application $app
* @param \Illuminate\Foundation\Application $app
* @param \Orchestra\Resources\Dispatcher $dispatcher
* @param \Orchestra\Resources\Response $response
* @return void
*/
public function __construct($app, Dispatcher $dispatcher, Response $response)
Expand All @@ -47,12 +49,12 @@ public function __construct($app, Dispatcher $dispatcher, Response $response)
}

/**
* Register a new resource
* Register a new resource.
*
* @access public
* @param string $name
* @param mixed $attributes
* @return Orchestra\Resources\Container
* @return \Orchestra\Resources\Container
*/
public function make($name, $attributes)
{
Expand All @@ -65,7 +67,7 @@ public function make($name, $attributes)
* @access public
* @param string $name
* @param mixed $attributes
* @return self
* @return \Orchestra\Resources\Container
*/
public function of($name, $attributes = null)
{
Expand All @@ -83,7 +85,7 @@ public function of($name, $attributes = null)
* @access public
* @param string $name
* @param array $parameters
* @return Response
* @return \Orchestra\Resources\Response
*/
public function call($name, $parameters = array())
{
Expand Down Expand Up @@ -111,7 +113,7 @@ public function call($name, $parameters = array())
* @access public
* @param mixed $content
* @param Closure $callback
* @return Illuminate\Http\Response
* @return mixed
*/
public function response($content, Closure $callback = null)
{
Expand Down
8 changes: 4 additions & 4 deletions src/Orchestra/Resources/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ class Response {
/**
* Application instance.
*
* @var Illuminate\Foundation\Application
* @var \Illuminate\Foundation\Application
*/
protected $app = null;

/**
* Construct a new Resources instance.
*
* @access public
* @param Illuminate\Foundation\Application $app
* @param \Illuminate\Foundation\Application $app
* @return void
*/
public function __construct($app)
Expand All @@ -32,8 +32,8 @@ public function __construct($app)
*
* @access public
* @param mixed $content
* @param Closure $callback
* @return Illuminate\Http\Response
* @param \Closure $callback
* @return mixed
*/
public function call($content, Closure $callback = null)
{
Expand Down

0 comments on commit c4a1657

Please sign in to comment.