Skip to content
Permalink
Browse files

Using the new trait and simplifying code

  • Loading branch information...
lorenzo committed Mar 25, 2016
1 parent a5e410c commit 770016d618977ff6d1b0743bef5e4878684afd6c
@@ -15,7 +15,7 @@
namespace Cake\Database\Expression;
use Cake\Database\ExpressionInterface;
use Cake\Database\Type\TypeExpressionCasterTrait;
use Cake\Database\Type\ExpressionTypeCasterTrait;
use Cake\Database\ValueBinder;
/**
@@ -27,7 +27,7 @@ class BetweenExpression implements ExpressionInterface, FieldInterface
{
use FieldTrait;
use TypeExpressionCasterTrait;
use ExpressionTypeCasterTrait;
/**
* The first value in the expression
@@ -15,7 +15,7 @@
namespace Cake\Database\Expression;
use Cake\Database\ExpressionInterface;
use Cake\Database\Type\TypeExpressionCasterTrait;
use Cake\Database\Type\ExpressionTypeCasterTrait;
use Cake\Database\ValueBinder;
/**
@@ -26,7 +26,7 @@
class CaseExpression implements ExpressionInterface
{
use TypeExpressionCasterTrait;
use ExpressionTypeCasterTrait;
/**
* A list of strings or other expression objects that represent the conditions of
@@ -16,7 +16,7 @@
use Cake\Database\Exception as DatabaseException;
use Cake\Database\ExpressionInterface;
use Cake\Database\Type\TypeExpressionCasterTrait;
use Cake\Database\Type\ExpressionTypeCasterTrait;
use Cake\Database\ValueBinder;
/**
@@ -30,7 +30,7 @@ class Comparison implements ExpressionInterface, FieldInterface
{
use FieldTrait;
use TypeExpressionCasterTrait;
use ExpressionTypeCasterTrait;
/**
* The value to be used in the right hand side of the operation
@@ -15,7 +15,7 @@
namespace Cake\Database\Expression;
use Cake\Database\ExpressionInterface;
use Cake\Database\Type\TypeExpressionCasterTrait;
use Cake\Database\Type\ExpressionTypeCasterTrait;
use Cake\Database\TypedResultInterface;
use Cake\Database\TypedResultTrait;
use Cake\Database\ValueBinder;
@@ -32,7 +32,7 @@ class FunctionExpression extends QueryExpression implements TypedResultInterface
{
use TypedResultTrait;
use TypeExpressionCasterTrait;
use ExpressionTypeCasterTrait;
/**
* The name of the function to be constructed when generating the SQL string
@@ -22,7 +22,7 @@
* if the type they should be converted to implements ExpressionTypeInterface
*
*/
trait TypeExpressionCasterTrait
trait ExpressionTypeCasterTrait
{
/**
@@ -50,11 +50,7 @@ protected function _castToExpression($value, $type)
$multi = $type !== $baseType;
if ($multi) {
$result = [];
foreach ($value as $k => $v) {
$result[$k] = $converter->toExpression($v);
}
return $result;
return array_map([$converter, 'toExpression'], $value);
}
return $converter->toExpression($value);

0 comments on commit 770016d

Please sign in to comment.
You can’t perform that action at this time.