Completed
Push — master ( 7c9586...c8ce39 )
by Oscar
01:44
created

Boolean::format()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace SimpleCrud\Fields;
4
5
use Atlas\Query\Insert;
6
use Atlas\Query\Update;
7
8
final class Boolean extends Field
9
{
10
    public function insert(Insert $query, $value)
11
    {
12
        $query->column($this->info['name'], (int) $this->format($value));
13
    }
14
15
    public function update(Update $query, $value)
16
    {
17
        $query->column($this->info['name'], (int) $this->format($value));
18
    }
19
20
    public function format($value): bool
21
    {
22
        return filter_var($value, FILTER_VALIDATE_BOOLEAN);
23
    }
24
}
25