for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Lukeraymonddowning\Mula\Casts;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
use Illuminate\Support\Str;
use Lukeraymonddowning\Mula\Facades;
class Mula implements CastsAttributes
{
protected $columns = [];
public function __construct(...$columns)
$this->columns = $columns;
}
public function get($model, string $key, $money, array $attributes)
return Facades\Mula::create(...$this->getMonetaryValues($money, $attributes));
$this->getMonetaryValues($money, $attributes)
array
string
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
protected function getMonetaryValues($money, $attributes)
return $this->expectsCurrencyAndAmountInSameColumn()
? explode('|', $money, 2)
: [$attributes[$this->columns[0]], $attributes[$this->columns[1]]];
protected function expectsCurrencyAndAmountInSameColumn()
return empty($this->columns);
public function set($model, string $key, $money, array $attributes)
if ($this->expectsCurrencyAndAmountInSameColumn()) {
return "{$money->value()}|{$money->currency()}";
return [
$this->columns[0] => $money->value(),
$this->columns[1] => $money->currency()
];
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: