Skip to content

Commit 770016d

Browse files
committed
Using the new trait and simplifying code
1 parent a5e410c commit 770016d

File tree

5 files changed

+10
-14
lines changed

5 files changed

+10
-14
lines changed

src/Database/Expression/BetweenExpression.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
namespace Cake\Database\Expression;
1616

1717
use Cake\Database\ExpressionInterface;
18-
use Cake\Database\Type\TypeExpressionCasterTrait;
18+
use Cake\Database\Type\ExpressionTypeCasterTrait;
1919
use Cake\Database\ValueBinder;
2020

2121
/**
@@ -27,7 +27,7 @@ class BetweenExpression implements ExpressionInterface, FieldInterface
2727
{
2828

2929
use FieldTrait;
30-
use TypeExpressionCasterTrait;
30+
use ExpressionTypeCasterTrait;
3131

3232
/**
3333
* The first value in the expression

src/Database/Expression/CaseExpression.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
namespace Cake\Database\Expression;
1616

1717
use Cake\Database\ExpressionInterface;
18-
use Cake\Database\Type\TypeExpressionCasterTrait;
18+
use Cake\Database\Type\ExpressionTypeCasterTrait;
1919
use Cake\Database\ValueBinder;
2020

2121
/**
@@ -26,7 +26,7 @@
2626
class CaseExpression implements ExpressionInterface
2727
{
2828

29-
use TypeExpressionCasterTrait;
29+
use ExpressionTypeCasterTrait;
3030

3131
/**
3232
* A list of strings or other expression objects that represent the conditions of

src/Database/Expression/Comparison.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
use Cake\Database\Exception as DatabaseException;
1818
use Cake\Database\ExpressionInterface;
19-
use Cake\Database\Type\TypeExpressionCasterTrait;
19+
use Cake\Database\Type\ExpressionTypeCasterTrait;
2020
use Cake\Database\ValueBinder;
2121

2222
/**
@@ -30,7 +30,7 @@ class Comparison implements ExpressionInterface, FieldInterface
3030
{
3131

3232
use FieldTrait;
33-
use TypeExpressionCasterTrait;
33+
use ExpressionTypeCasterTrait;
3434

3535
/**
3636
* The value to be used in the right hand side of the operation

src/Database/Expression/FunctionExpression.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
namespace Cake\Database\Expression;
1616

1717
use Cake\Database\ExpressionInterface;
18-
use Cake\Database\Type\TypeExpressionCasterTrait;
18+
use Cake\Database\Type\ExpressionTypeCasterTrait;
1919
use Cake\Database\TypedResultInterface;
2020
use Cake\Database\TypedResultTrait;
2121
use Cake\Database\ValueBinder;
@@ -32,7 +32,7 @@ class FunctionExpression extends QueryExpression implements TypedResultInterface
3232
{
3333

3434
use TypedResultTrait;
35-
use TypeExpressionCasterTrait;
35+
use ExpressionTypeCasterTrait;
3636

3737
/**
3838
* The name of the function to be constructed when generating the SQL string

src/Database/Type/ExpressionTypeCasterTrait.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* if the type they should be converted to implements ExpressionTypeInterface
2323
*
2424
*/
25-
trait TypeExpressionCasterTrait
25+
trait ExpressionTypeCasterTrait
2626
{
2727

2828
/**
@@ -50,11 +50,7 @@ protected function _castToExpression($value, $type)
5050
$multi = $type !== $baseType;
5151

5252
if ($multi) {
53-
$result = [];
54-
foreach ($value as $k => $v) {
55-
$result[$k] = $converter->toExpression($v);
56-
}
57-
return $result;
53+
return array_map([$converter, 'toExpression'], $value);
5854
}
5955

6056
return $converter->toExpression($value);

0 commit comments

Comments
 (0)