2023-08-08 23:53:49 -04:00
|
|
|
<?php
|
|
|
|
namespace Incoviba\Common\Implement\Repository\Mapper;
|
|
|
|
|
|
|
|
use Incoviba\Common\Implement\Repository\Mapper;
|
|
|
|
|
|
|
|
class Boolean extends Mapper
|
|
|
|
{
|
2023-09-13 18:51:46 -03:00
|
|
|
public function __construct(string $column, ?string $property = null, bool $default = false)
|
2023-08-08 23:53:49 -04:00
|
|
|
{
|
|
|
|
$this->setFunction(function($data) use ($column) {
|
|
|
|
return $data[$column] !== 0;
|
|
|
|
});
|
2023-09-13 18:51:46 -03:00
|
|
|
$this->setDefault($default);
|
2023-08-08 23:53:49 -04:00
|
|
|
if ($property !== null) {
|
|
|
|
$this->setProperty($property);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|