Applied fixes from StyleCI

This commit is contained in:
Casper Rasmussen 2016-07-28 05:56:24 -04:00 committed by StyleCI Bot
parent d225edabb2
commit f8d6534fcc
13 changed files with 79 additions and 95 deletions

View File

@ -1,4 +1,5 @@
<?php <?php
namespace Nodes\CounterCache; namespace Nodes\CounterCache;
use Illuminate\Database\Eloquent\Model as IlluminateModel; use Illuminate\Database\Eloquent\Model as IlluminateModel;
@ -11,20 +12,17 @@ use Nodes\CounterCache\Exceptions\NotCounterCacheableException;
use Nodes\CounterCache\Exceptions\RelationNotFoundException; use Nodes\CounterCache\Exceptions\RelationNotFoundException;
/** /**
* Class CounterCache * Class CounterCache.
*
* @package Nodes\CounterCache
*/ */
class CounterCache class CounterCache
{ {
/** /**
* Perform counter caching on model * Perform counter caching on model.
* *
* @author Morten Rugaard <moru@nodes.dk> * @author Morten Rugaard <moru@nodes.dk>
* *
* @access public
* @param \Illuminate\Database\Eloquent\Model $model * @param \Illuminate\Database\Eloquent\Model $model
* @return boolean * @return bool
* @throws \Nodes\CounterCache\Exceptions\NoCounterCachesFound * @throws \Nodes\CounterCache\Exceptions\NoCounterCachesFound
* @throws \Nodes\CounterCache\Exceptions\NotCounterCacheableException * @throws \Nodes\CounterCache\Exceptions\NotCounterCacheableException
* @throws \Nodes\CounterCache\Exceptions\RelationNotFoundException * @throws \Nodes\CounterCache\Exceptions\RelationNotFoundException
@ -88,13 +86,12 @@ class CounterCache
} }
/** /**
* Perform counter caching on all entities of model * Perform counter caching on all entities of model.
* *
* @author Morten Rugaard <moru@nodes.dk> * @author Morten Rugaard <moru@nodes.dk>
* *
* @access public
* @param \Illuminate\Database\Eloquent\Model $model * @param \Illuminate\Database\Eloquent\Model $model
* @return boolean * @return bool
* @throws \Nodes\CounterCache\Exceptions\NoEntitiesFoundException * @throws \Nodes\CounterCache\Exceptions\NoEntitiesFoundException
* @throws \Nodes\CounterCache\Exceptions\NoCounterCachesFound * @throws \Nodes\CounterCache\Exceptions\NoCounterCachesFound
* @throws \Nodes\CounterCache\Exceptions\NotCounterCacheableException * @throws \Nodes\CounterCache\Exceptions\NotCounterCacheableException
@ -121,17 +118,16 @@ class CounterCache
} }
/** /**
* Update counter cache column * Update counter cache column.
* *
* @author Morten Rugaard <moru@nodes.dk> * @author Morten Rugaard <moru@nodes.dk>
* *
* @access protected
* @param \Illuminate\Database\Eloquent\Model $model * @param \Illuminate\Database\Eloquent\Model $model
* @param \Illuminate\Database\Eloquent\Relations\Relation $relation * @param \Illuminate\Database\Eloquent\Relations\Relation $relation
* @param array|null $counterCacheConditions * @param array|null $counterCacheConditions
* @param string $foreignKey * @param string $foreignKey
* @param string $counterCacheColumnName * @param string $counterCacheColumnName
* @return boolean * @return bool
*/ */
protected function updateCount(IlluminateModel $model, IlluminateRelation $relation, $counterCacheConditions, $foreignKey, $counterCacheColumnName) protected function updateCount(IlluminateModel $model, IlluminateRelation $relation, $counterCacheConditions, $foreignKey, $counterCacheColumnName)
{ {
@ -166,18 +162,17 @@ class CounterCache
// Fire the update query // Fire the update query
// to update counter cache column // to update counter cache column
return (bool) $relation->getBaseQuery()->update([ return (bool) $relation->getBaseQuery()->update([
sprintf('%s.%s', $relationTableName, $counterCacheColumnName) => DB::raw(sprintf('(%s)', vsprintf($countQuerySql, $countQuery->getBindings()))) sprintf('%s.%s', $relationTableName, $counterCacheColumnName) => DB::raw(sprintf('(%s)', vsprintf($countQuerySql, $countQuery->getBindings()))),
]); ]);
} }
/** /**
* Prepare value for SQL insertion * Prepare value for SQL insertion.
* *
* @author Morten Rugaard <moru@nodes.dk> * @author Morten Rugaard <moru@nodes.dk>
* *
* @access public
* @param string $value * @param string $value
* @return integer|string * @return int|string
*/ */
private function prepareValue($value) private function prepareValue($value)
{ {

View File

@ -1,20 +1,19 @@
<?php <?php
namespace Nodes\CounterCache; namespace Nodes\CounterCache;
/** /**
* Interface CounterCacheable * Interface CounterCacheable.
* *
* @interface * @interface
* @package Nodes\CounterCache
*/ */
interface CounterCacheable interface CounterCacheable
{ {
/** /**
* Retrieve array of counter caches * Retrieve array of counter caches.
* *
* @author Morten Rugaard <moru@nodes.dk> * @author Morten Rugaard <moru@nodes.dk>
* *
* @access public
* @return array * @return array
*/ */
public function counterCaches(); public function counterCaches();

View File

@ -1,25 +1,23 @@
<?php <?php
namespace Nodes\CounterCache\Exceptions; namespace Nodes\CounterCache\Exceptions;
use Nodes\Exceptions\Exception as NodesException; use Nodes\Exceptions\Exception as NodesException;
/** /**
* Class CounterCacheException * Class CounterCacheException.
*
* @package Nodes\CounterCache\Exceptions
*/ */
class CounterCacheException extends NodesException class CounterCacheException extends NodesException
{ {
/** /**
* CounterCacheException constructor * CounterCacheException constructor.
* *
* @author Morten Rugaard <moru@nodes.dk> * @author Morten Rugaard <moru@nodes.dk>
* *
* @access public
* @param string $message * @param string $message
* @param integer $code * @param int $code
* @param array $headers * @param array $headers
* @param boolean $report * @param bool $report
* @param string $severity * @param string $severity
*/ */
public function __construct($message = 'Counter cache failed', $code = 500, array $headers = [], $report = true, $severity = 'error') public function __construct($message = 'Counter cache failed', $code = 500, array $headers = [], $report = true, $severity = 'error')

View File

@ -1,23 +1,21 @@
<?php <?php
namespace Nodes\CounterCache\Exceptions; namespace Nodes\CounterCache\Exceptions;
/** /**
* Class NoCounterCachesFound * Class NoCounterCachesFound.
*
* @package Nodes\CounterCache\Exceptions
*/ */
class NoCounterCachesFound extends CounterCacheException class NoCounterCachesFoundException extends CounterCacheException
{ {
/** /**
* NoCounterCachesFound constructor * NoCounterCachesFound constructor.
* *
* @author Morten Rugaard <moru@nodes.dk> * @author Morten Rugaard <moru@nodes.dk>
* *
* @access public
* @param string $message * @param string $message
* @param integer $code * @param int $code
* @param array $headers * @param array $headers
* @param boolean $report * @param bool $report
* @param string $severity * @param string $severity
*/ */
public function __construct($message = 'No counter caches found on model', $code = 500, array $headers = [], $report = true, $severity = 'error') public function __construct($message = 'No counter caches found on model', $code = 500, array $headers = [], $report = true, $severity = 'error')

View File

@ -1,23 +1,21 @@
<?php <?php
namespace Nodes\CounterCache\Exceptions; namespace Nodes\CounterCache\Exceptions;
/** /**
* Class NoEntitiesFoundException * Class NoEntitiesFoundException.
*
* @package Nodes\CounterCache\Exceptions
*/ */
class NoEntitiesFoundException extends CounterCacheException class NoEntitiesFoundException extends CounterCacheException
{ {
/** /**
* NoEntitiesFoundException constructor * NoEntitiesFoundException constructor.
* *
* @author Morten Rugaard <moru@nodes.dk> * @author Morten Rugaard <moru@nodes.dk>
* *
* @access public
* @param string $message * @param string $message
* @param integer $code * @param int $code
* @param array $headers * @param array $headers
* @param boolean $report * @param bool $report
* @param string $severity * @param string $severity
*/ */
public function __construct($message = 'No entities found', $code = 500, array $headers = [], $report = true, $severity = 'error') public function __construct($message = 'No entities found', $code = 500, array $headers = [], $report = true, $severity = 'error')

View File

@ -1,23 +1,21 @@
<?php <?php
namespace Nodes\CounterCache\Exceptions; namespace Nodes\CounterCache\Exceptions;
/** /**
* Class NotCounterCacheableException * Class NotCounterCacheableException.
*
* @package Nodes\CounterCache\Exceptions
*/ */
class NotCounterCacheableException extends CounterCacheException class NotCounterCacheableException extends CounterCacheException
{ {
/** /**
* NotCounterCacheableException constructor * NotCounterCacheableException constructor.
* *
* @author Morten Rugaard <moru@nodes.dk> * @author Morten Rugaard <moru@nodes.dk>
* *
* @access public
* @param string $message * @param string $message
* @param integer $code * @param int $code
* @param array $headers * @param array $headers
* @param boolean $report * @param bool $report
* @param string $severity * @param string $severity
*/ */
public function __construct($message = 'Model does not implement CounterCacheable', $code = 500, array $headers = [], $report = true, $severity = 'error') public function __construct($message = 'Model does not implement CounterCacheable', $code = 500, array $headers = [], $report = true, $severity = 'error')

View File

@ -1,23 +1,21 @@
<?php <?php
namespace Nodes\CounterCache\Exceptions; namespace Nodes\CounterCache\Exceptions;
/** /**
* Class RelationNotFoundException * Class RelationNotFoundException.
*
* @package Nodes\CounterCache\Exceptions
*/ */
class RelationNotFoundException extends CounterCacheException class RelationNotFoundException extends CounterCacheException
{ {
/** /**
* RelationNotFoundException constructor * RelationNotFoundException constructor.
* *
* @author Morten Rugaard <moru@nodes.dk> * @author Morten Rugaard <moru@nodes.dk>
* *
* @access public
* @param string $message * @param string $message
* @param integer $code * @param int $code
* @param array $headers * @param array $headers
* @param boolean $report * @param bool $report
* @param string $severity * @param string $severity
*/ */
public function __construct($message = 'Relation not found on model', $code = 500, array $headers = [], $report = true, $severity = 'error') public function __construct($message = 'Relation not found on model', $code = 500, array $headers = [], $report = true, $severity = 'error')

View File

@ -1,11 +1,11 @@
<?php <?php
namespace Nodes\CounterCache\Traits; namespace Nodes\CounterCache\Traits;
/** /**
* Trait CounterCache * Trait CounterCache.
* *
* @trait * @trait
* @package Nodes\CounterCache\Traits
*/ */
trait CounterCache trait CounterCache
{ {

View File

@ -1,16 +1,16 @@
<?php <?php
namespace Nodes\CounterCache\Traits; namespace Nodes\CounterCache\Traits;
/** /**
* Trait CounterCacheCreated * Trait CounterCacheCreated.
* *
* @trait * @trait
* @package Nodes\CounterCache\Traits
*/ */
trait CounterCacheCreated trait CounterCacheCreated
{ {
/** /**
* The "booting" of trait * The "booting" of trait.
* *
* @author Morten Rugaard <moru@nodes.dk> * @author Morten Rugaard <moru@nodes.dk>
* *

View File

@ -1,16 +1,16 @@
<?php <?php
namespace Nodes\CounterCache\Traits; namespace Nodes\CounterCache\Traits;
/** /**
* Trait CounterCacheDeleted * Trait CounterCacheDeleted.
* *
* @trait * @trait
* @package Nodes\CounterCache\Traits
*/ */
trait CounterCacheDeleted trait CounterCacheDeleted
{ {
/** /**
* The "booting" of trait * The "booting" of trait.
* *
* @author Morten Rugaard <moru@nodes.dk> * @author Morten Rugaard <moru@nodes.dk>
* *

View File

@ -1,16 +1,16 @@
<?php <?php
namespace Nodes\CounterCache\Traits; namespace Nodes\CounterCache\Traits;
/** /**
* Trait CounterCacheRestored * Trait CounterCacheRestored.
* *
* @trait * @trait
* @package Nodes\CounterCache\Traits
*/ */
trait CounterCacheRestored trait CounterCacheRestored
{ {
/** /**
* The "booting" of trait * The "booting" of trait.
* *
* @author Morten Rugaard <moru@nodes.dk> * @author Morten Rugaard <moru@nodes.dk>
* *

View File

@ -1,16 +1,16 @@
<?php <?php
namespace Nodes\CounterCache\Traits; namespace Nodes\CounterCache\Traits;
/** /**
* Trait CounterCacheSaved * Trait CounterCacheSaved.
* *
* @trait * @trait
* @package Nodes\CounterCache\Traits
*/ */
trait CounterCacheSaved trait CounterCacheSaved
{ {
/** /**
* The "booting" of trait * The "booting" of trait.
* *
* @author Morten Rugaard <moru@nodes.dk> * @author Morten Rugaard <moru@nodes.dk>
* *

View File

@ -1,16 +1,16 @@
<?php <?php
namespace Nodes\CounterCache\Traits; namespace Nodes\CounterCache\Traits;
/** /**
* Trait CounterCacheUpdated * Trait CounterCacheUpdated.
* *
* @trait * @trait
* @package Nodes\CounterCache\Traits
*/ */
trait CounterCacheUpdated trait CounterCacheUpdated
{ {
/** /**
* The "booting" of trait * The "booting" of trait.
* *
* @author Morten Rugaard <moru@nodes.dk> * @author Morten Rugaard <moru@nodes.dk>
* *