Merge pull request #2 from nodes-php/analysis-qo7995
Applied fixes from StyleCI
This commit is contained in:
commit
18506a8b7e
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Nodes\CounterCache;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model as IlluminateModel;
|
||||
|
@ -11,20 +12,17 @@ use Nodes\CounterCache\Exceptions\NotCounterCacheableException;
|
|||
use Nodes\CounterCache\Exceptions\RelationNotFoundException;
|
||||
|
||||
/**
|
||||
* 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>
|
||||
*
|
||||
* @access public
|
||||
* @param \Illuminate\Database\Eloquent\Model $model
|
||||
* @return boolean
|
||||
* @return bool
|
||||
* @throws \Nodes\CounterCache\Exceptions\NoCounterCachesFound
|
||||
* @throws \Nodes\CounterCache\Exceptions\NotCounterCacheableException
|
||||
* @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>
|
||||
*
|
||||
* @access public
|
||||
* @param \Illuminate\Database\Eloquent\Model $model
|
||||
* @return boolean
|
||||
* @return bool
|
||||
* @throws \Nodes\CounterCache\Exceptions\NoEntitiesFoundException
|
||||
* @throws \Nodes\CounterCache\Exceptions\NoCounterCachesFound
|
||||
* @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>
|
||||
*
|
||||
* @access protected
|
||||
* @param \Illuminate\Database\Eloquent\Model $model
|
||||
* @param \Illuminate\Database\Eloquent\Relations\Relation $relation
|
||||
* @param array|null $counterCacheConditions
|
||||
* @param string $foreignKey
|
||||
* @param string $counterCacheColumnName
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
protected function updateCount(IlluminateModel $model, IlluminateRelation $relation, $counterCacheConditions, $foreignKey, $counterCacheColumnName)
|
||||
{
|
||||
|
@ -166,18 +162,17 @@ class CounterCache
|
|||
// Fire the update query
|
||||
// to update counter cache column
|
||||
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>
|
||||
*
|
||||
* @access public
|
||||
* @param string $value
|
||||
* @return integer|string
|
||||
* @return int|string
|
||||
*/
|
||||
private function prepareValue($value)
|
||||
{
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace Nodes\CounterCache;
|
||||
|
||||
/**
|
||||
* Interface CounterCacheable
|
||||
* Interface CounterCacheable.
|
||||
*
|
||||
* @interface
|
||||
* @package Nodes\CounterCache
|
||||
*/
|
||||
interface CounterCacheable
|
||||
{
|
||||
/**
|
||||
* Retrieve array of counter caches
|
||||
* Retrieve array of counter caches.
|
||||
*
|
||||
* @author Morten Rugaard <moru@nodes.dk>
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function counterCaches();
|
||||
|
|
|
@ -1,25 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace Nodes\CounterCache\Exceptions;
|
||||
|
||||
use Nodes\Exceptions\Exception as NodesException;
|
||||
|
||||
/**
|
||||
* Class CounterCacheException
|
||||
*
|
||||
* @package Nodes\CounterCache\Exceptions
|
||||
* Class CounterCacheException.
|
||||
*/
|
||||
class CounterCacheException extends NodesException
|
||||
{
|
||||
/**
|
||||
* CounterCacheException constructor
|
||||
* CounterCacheException constructor.
|
||||
*
|
||||
* @author Morten Rugaard <moru@nodes.dk>
|
||||
*
|
||||
* @access public
|
||||
* @param string $message
|
||||
* @param integer $code
|
||||
* @param int $code
|
||||
* @param array $headers
|
||||
* @param boolean $report
|
||||
* @param bool $report
|
||||
* @param string $severity
|
||||
*/
|
||||
public function __construct($message = 'Counter cache failed', $code = 500, array $headers = [], $report = true, $severity = 'error')
|
||||
|
|
|
@ -1,23 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Nodes\CounterCache\Exceptions;
|
||||
|
||||
/**
|
||||
* Class NoCounterCachesFound
|
||||
*
|
||||
* @package Nodes\CounterCache\Exceptions
|
||||
* Class NoCounterCachesFound.
|
||||
*/
|
||||
class NoCounterCachesFound extends CounterCacheException
|
||||
class NoCounterCachesFoundException extends CounterCacheException
|
||||
{
|
||||
/**
|
||||
* NoCounterCachesFound constructor
|
||||
* NoCounterCachesFound constructor.
|
||||
*
|
||||
* @author Morten Rugaard <moru@nodes.dk>
|
||||
*
|
||||
* @access public
|
||||
* @param string $message
|
||||
* @param integer $code
|
||||
* @param int $code
|
||||
* @param array $headers
|
||||
* @param boolean $report
|
||||
* @param bool $report
|
||||
* @param string $severity
|
||||
*/
|
||||
public function __construct($message = 'No counter caches found on model', $code = 500, array $headers = [], $report = true, $severity = 'error')
|
||||
|
|
|
@ -1,23 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Nodes\CounterCache\Exceptions;
|
||||
|
||||
/**
|
||||
* Class NoEntitiesFoundException
|
||||
*
|
||||
* @package Nodes\CounterCache\Exceptions
|
||||
* Class NoEntitiesFoundException.
|
||||
*/
|
||||
class NoEntitiesFoundException extends CounterCacheException
|
||||
{
|
||||
/**
|
||||
* NoEntitiesFoundException constructor
|
||||
* NoEntitiesFoundException constructor.
|
||||
*
|
||||
* @author Morten Rugaard <moru@nodes.dk>
|
||||
*
|
||||
* @access public
|
||||
* @param string $message
|
||||
* @param integer $code
|
||||
* @param int $code
|
||||
* @param array $headers
|
||||
* @param boolean $report
|
||||
* @param bool $report
|
||||
* @param string $severity
|
||||
*/
|
||||
public function __construct($message = 'No entities found', $code = 500, array $headers = [], $report = true, $severity = 'error')
|
||||
|
|
|
@ -1,23 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Nodes\CounterCache\Exceptions;
|
||||
|
||||
/**
|
||||
* Class NotCounterCacheableException
|
||||
*
|
||||
* @package Nodes\CounterCache\Exceptions
|
||||
* Class NotCounterCacheableException.
|
||||
*/
|
||||
class NotCounterCacheableException extends CounterCacheException
|
||||
{
|
||||
/**
|
||||
* NotCounterCacheableException constructor
|
||||
* NotCounterCacheableException constructor.
|
||||
*
|
||||
* @author Morten Rugaard <moru@nodes.dk>
|
||||
*
|
||||
* @access public
|
||||
* @param string $message
|
||||
* @param integer $code
|
||||
* @param int $code
|
||||
* @param array $headers
|
||||
* @param boolean $report
|
||||
* @param bool $report
|
||||
* @param string $severity
|
||||
*/
|
||||
public function __construct($message = 'Model does not implement CounterCacheable', $code = 500, array $headers = [], $report = true, $severity = 'error')
|
||||
|
|
|
@ -1,23 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Nodes\CounterCache\Exceptions;
|
||||
|
||||
/**
|
||||
* Class RelationNotFoundException
|
||||
*
|
||||
* @package Nodes\CounterCache\Exceptions
|
||||
* Class RelationNotFoundException.
|
||||
*/
|
||||
class RelationNotFoundException extends CounterCacheException
|
||||
{
|
||||
/**
|
||||
* RelationNotFoundException constructor
|
||||
* RelationNotFoundException constructor.
|
||||
*
|
||||
* @author Morten Rugaard <moru@nodes.dk>
|
||||
*
|
||||
* @access public
|
||||
* @param string $message
|
||||
* @param integer $code
|
||||
* @param int $code
|
||||
* @param array $headers
|
||||
* @param boolean $report
|
||||
* @param bool $report
|
||||
* @param string $severity
|
||||
*/
|
||||
public function __construct($message = 'Relation not found on model', $code = 500, array $headers = [], $report = true, $severity = 'error')
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace Nodes\CounterCache\Traits;
|
||||
|
||||
/**
|
||||
* Trait CounterCache
|
||||
* Trait CounterCache.
|
||||
*
|
||||
* @trait
|
||||
* @package Nodes\CounterCache\Traits
|
||||
*/
|
||||
trait CounterCache
|
||||
{
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace Nodes\CounterCache\Traits;
|
||||
|
||||
/**
|
||||
* Trait CounterCacheCreated
|
||||
* Trait CounterCacheCreated.
|
||||
*
|
||||
* @trait
|
||||
* @package Nodes\CounterCache\Traits
|
||||
*/
|
||||
trait CounterCacheCreated
|
||||
{
|
||||
/**
|
||||
* The "booting" of trait
|
||||
* The "booting" of trait.
|
||||
*
|
||||
* @author Morten Rugaard <moru@nodes.dk>
|
||||
*
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace Nodes\CounterCache\Traits;
|
||||
|
||||
/**
|
||||
* Trait CounterCacheDeleted
|
||||
* Trait CounterCacheDeleted.
|
||||
*
|
||||
* @trait
|
||||
* @package Nodes\CounterCache\Traits
|
||||
*/
|
||||
trait CounterCacheDeleted
|
||||
{
|
||||
/**
|
||||
* The "booting" of trait
|
||||
* The "booting" of trait.
|
||||
*
|
||||
* @author Morten Rugaard <moru@nodes.dk>
|
||||
*
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace Nodes\CounterCache\Traits;
|
||||
|
||||
/**
|
||||
* Trait CounterCacheRestored
|
||||
* Trait CounterCacheRestored.
|
||||
*
|
||||
* @trait
|
||||
* @package Nodes\CounterCache\Traits
|
||||
*/
|
||||
trait CounterCacheRestored
|
||||
{
|
||||
/**
|
||||
* The "booting" of trait
|
||||
* The "booting" of trait.
|
||||
*
|
||||
* @author Morten Rugaard <moru@nodes.dk>
|
||||
*
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace Nodes\CounterCache\Traits;
|
||||
|
||||
/**
|
||||
* Trait CounterCacheSaved
|
||||
* Trait CounterCacheSaved.
|
||||
*
|
||||
* @trait
|
||||
* @package Nodes\CounterCache\Traits
|
||||
*/
|
||||
trait CounterCacheSaved
|
||||
{
|
||||
/**
|
||||
* The "booting" of trait
|
||||
* The "booting" of trait.
|
||||
*
|
||||
* @author Morten Rugaard <moru@nodes.dk>
|
||||
*
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace Nodes\CounterCache\Traits;
|
||||
|
||||
/**
|
||||
* Trait CounterCacheUpdated
|
||||
* Trait CounterCacheUpdated.
|
||||
*
|
||||
* @trait
|
||||
* @package Nodes\CounterCache\Traits
|
||||
*/
|
||||
trait CounterCacheUpdated
|
||||
{
|
||||
/**
|
||||
* The "booting" of trait
|
||||
* The "booting" of trait.
|
||||
*
|
||||
* @author Morten Rugaard <moru@nodes.dk>
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue