Completed
Push — master ( 1ee05e...99144a )
by Gaetano
05:13
created

EzBoolean::hashToFieldValue()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 0
cts 2
cp 0
rs 10
cc 2
nc 1
nop 2
crap 6
1
<?php
2
3
namespace Kaliop\eZMigrationBundle\Core\FieldHandler;
4
5
use eZ\Publish\Core\FieldType\Checkbox\Value as CheckboxValue;
6
use Kaliop\eZMigrationBundle\API\FieldValueImporterInterface;
7
8
class EzBoolean extends AbstractFieldHandler implements FieldValueImporterInterface
9
{
10
    /**
11
     * Creates a value object to use as the field value when setting a boolean field type.
12
     *
13
     * @param $fieldValue int:string:bool should all work
14
     * @param array $context The context for execution of the current migrations. Contains f.e. the path to the migration
15
     * @return CheckboxValue
16
     */
17
    public function hashToFieldValue($fieldValue, array $context = array())
18
    {
19
        return new CheckboxValue(($fieldValue == 1) ? true : false);
20
    }
21
}
22