Skip to content

Commit

Permalink
Improves contracts and update few docblocks
Browse files Browse the repository at this point in the history
Signed-off-by: crynobone <crynobone@gmail.com>
  • Loading branch information
crynobone committed Nov 8, 2014
1 parent 44c2820 commit 596cd3b
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 65 deletions.
2 changes: 1 addition & 1 deletion src/Support/Expression.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Expression
/**
* Create a new expression instance.
*
* @param string $value
* @param string $value
*/
public function __construct($value)
{
Expand Down
5 changes: 2 additions & 3 deletions src/Support/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ abstract class Manager extends \Illuminate\Support\Manager
*
* @param string $driver
* @return object
* @see Manager::driver()
*/
public function make($driver = null)
{
Expand All @@ -26,7 +25,7 @@ public function make($driver = null)
/**
* Create a new driver instance.
*
* @param string $driverName
* @param string $driverName
* @return object
*/
protected function createDriver($driverName)
Expand All @@ -51,7 +50,7 @@ protected function createDriver($driverName)
/**
* Call a custom driver creator.
*
* @param string $driverName
* @param string $driverName
* @return object
*/
protected function callCustomCreator($driverName)
Expand Down
2 changes: 1 addition & 1 deletion src/Support/Morph.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static function __callStatic($method, $parameters)
* Determine if method is callable.
*
* @param string $method
* @return boolean
* @return bool
*/
public static function isCallable($method)
{
Expand Down
41 changes: 20 additions & 21 deletions src/Support/Nesty.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php namespace Orchestra\Support;

use Illuminate\Support\Arr;
use Illuminate\Support\Fluent;
use Orchestra\Support\Traits\DescendibleTrait;

Expand All @@ -12,41 +13,39 @@ class Nesty
*
* @var array
*/
protected $items = array();
protected $items = [];

/**
* Configuration.
*
* @var array
*/
protected $config = array();
protected $config = [];

/**
* Construct a new instance.
*
* @param array $config
* @return void
* @param array $config
*/
public function __construct(array $config = array())
public function __construct(array $config = [])
{
$this->config = $config;
}

/**
* Create a new Fluent instance while appending default config.
*
* @param integer $id
* @param int $id
* @return \Illuminate\Support\Fluent
*/
protected function toFluent($id)
{
$defaults = isset($this->config['defaults']) ?
$this->config['defaults'] : array();
$defaults = Arr::get($this->config, 'defaults', []);

return new Fluent(array_merge($defaults, array(
return new Fluent(array_merge($defaults, [
'id' => $id,
'childs' => array(),
)));
'childs' => [],
]));
}

/**
Expand All @@ -58,7 +57,7 @@ protected function toFluent($id)
*/
protected function addBefore($id, $before)
{
$items = array();
$items = [];
$item = $this->toFluent($id);
$keys = array_keys($this->items);
$position = array_search($before, $keys);
Expand Down Expand Up @@ -129,7 +128,7 @@ protected function addChild($id, $parent)
return null;
}

$item = $node->childs;
$item = $node->get('childs');
$item[$id] = $this->toFluent($id);

$node->childs($item);
Expand All @@ -149,10 +148,10 @@ protected function addParent($id)
}

/**
* Add a new item, prepending or appending
* Add a new item, by prepend or append.
*
* @param string $id
* @param string $location
* @param string $id
* @param string $location
* @return \Illuminate\Support\Fluent
*/
public function add($id, $location = '#')
Expand All @@ -169,18 +168,18 @@ public function add($id, $location = '#')
/**
* Pick traverse from matched expression.
*
* @param string $id
* @param string $key
* @param string $location
* @param string $id
* @param string $key
* @param string $location
* @return \Illuminate\Support\Fluent
*/
protected function pickTraverseFromMatchedExpression($id, $key, $location)
{
$matching = array(
$matching = [
'<' => 'addBefore',
'>' => 'addAfter',
'^' => 'addChild',
);
];

$method = $matching[$key];

Expand Down
14 changes: 7 additions & 7 deletions src/Support/Traits/ControllerResponseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ trait ControllerResponseTrait
/**
* Queue notification and redirect.
*
* @param string $to
* @param string $message
* @param string $type
* @param string $to
* @param string $message
* @param string $type
* @return mixed
*/
public function redirectWithMessage($to, $message = null, $type = 'success')
Expand All @@ -26,8 +26,8 @@ public function redirectWithMessage($to, $message = null, $type = 'success')
/**
* Queue notification and redirect.
*
* @param string $to
* @param mixed $errors
* @param string $to
* @param mixed $errors
* @return mixed
*/
public function redirectWithErrors($to, $errors)
Expand All @@ -38,7 +38,7 @@ public function redirectWithErrors($to, $errors)
/**
* Redirect.
*
* @param string $to
* @param string $to
* @return mixed
*/
public function redirect($to)
Expand All @@ -49,7 +49,7 @@ public function redirect($to)
/**
* Halt current request using App::abort().
*
* @param int $code
* @param int $code
* @return void
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
Expand Down
2 changes: 1 addition & 1 deletion src/Support/Traits/DataContainerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function set($key, $value = null)
* Check if item key has a value.
*
* @param string $key
* @return boolean
* @return bool
*/
public function has($key)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Support/Traits/DescendibleTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ protected function descendants(array $array, $key = null)
/**
* Resolve last descendant node from items.
*
* @param array $array
* @param array $key
* @param array $array
* @param array $keys
* @return \Illuminate\Support\Fluent
*/
protected function resolveLastDecendant($array, $keys)
Expand Down
6 changes: 3 additions & 3 deletions src/Support/Traits/MacroableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait MacroableTrait
/**
* Register a custom HTML macro.
*
* @param string $name
* @param string $name
* @param callable $macro
* @return void
*/
Expand All @@ -24,8 +24,8 @@ public function macro($name, $macro)
/**
* Dynamically handle calls to the html class.
*
* @param string $method
* @param array $parameters
* @param string $method
* @param array $parameters
* @return mixed
* @throws \BadMethodCallException
*/
Expand Down
14 changes: 7 additions & 7 deletions src/Support/Traits/ObservableTrait.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php namespace Orchestra\Support\Traits;

use Illuminate\Events\Dispatcher;
use Illuminate\Contracts\Events\Dispatcher;

trait ObservableTrait
{
/**
* The event dispatcher instance.
*
* @var \Illuminate\Events\Dispatcher
* @var \Illuminate\Contracts\Events\Dispatcher
*/
protected static $dispatcher;

Expand Down Expand Up @@ -54,8 +54,8 @@ public function getObservableEvents()
/**
* Register an event with the dispatcher.
*
* @param string $event
* @param \Closure|string $callback
* @param string $event
* @param \Closure|string $callback
* @return void
*/
protected static function registerObservableEvent($event, $callback)
Expand All @@ -75,7 +75,7 @@ protected static function registerObservableEvent($event, $callback)
* Fire the given event.
*
* @param string $event
* @param boolean $halt
* @param bool $halt
* @return mixed
*/
protected function fireObservableEvent($event, $halt)
Expand Down Expand Up @@ -116,7 +116,7 @@ public static function flushEventListeners()
/**
* Get the event dispatcher instance.
*
* @return \Illuminate\Events\Dispatcher
* @return \Illuminate\Contracts\Events\Dispatcher
*/
public static function getEventDispatcher()
{
Expand All @@ -126,7 +126,7 @@ public static function getEventDispatcher()
/**
* Set the event dispatcher instance.
*
* @param \Illuminate\Events\Dispatcher $dispatcher
* @param \Illuminate\Contracts\Events\Dispatcher $dispatcher
* @return void
*/
public static function setEventDispatcher(Dispatcher $dispatcher)
Expand Down
10 changes: 5 additions & 5 deletions src/Support/Traits/QueryFilterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ trait QueryFilterTrait
/**
* Setup basic query string filter to eloquent or query builder.
*
* @param \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder $query
* @param array $input
* @param \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder $query
* @param array $input
* @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder
*/
protected function setupBasicQueryFilter($query, array $input = array())
Expand All @@ -36,9 +36,9 @@ protected function setupBasicQueryFilter($query, array $input = array())
/**
* Setup wildcard query string filter to eloquent or query builder.
*
* @param \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder $query
* @param mixed $keyword
* @param array $fields
* @param \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder $query
* @param mixed $keyword
* @param array $fields
* @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder
*/
protected function setupWildcardQueryFilter($query, $keyword, array $fields)
Expand Down
8 changes: 4 additions & 4 deletions src/Support/Traits/UploadableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ trait UploadableTrait
/**
* Save uploaded file into directory.
*
* @param \Symfony\Component\HttpFoundation\File\UploadedFile $file
* @param string $path
* @param \Symfony\Component\HttpFoundation\File\UploadedFile $file
* @param string $path
* @return string
*/
protected function saveUploadedFile(UploadedFile $file, $path)
Expand All @@ -23,7 +23,7 @@ protected function saveUploadedFile(UploadedFile $file, $path)
/**
* Delete uploaded from directory
*
* @param string $file
* @param string $file
* @return bool
*/
protected function deleteUploadedFile($file)
Expand All @@ -34,7 +34,7 @@ protected function deleteUploadedFile($file)
/**
* Get uploaded filename.
*
* @param \Symfony\Component\HttpFoundation\File\UploadedFile $file
* @param \Symfony\Component\HttpFoundation\File\UploadedFile $file
* @return string
*/
protected function getUploadedFilename(UploadedFile $file)
Expand Down
Loading

0 comments on commit 596cd3b

Please sign in to comment.