Completed
Push — master ( f113dc...290d49 )
by Gaetano
17:56 queued 14:34
created

EzBoolean::hashToFieldValue()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 1
nop 2
crap 2
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 1
    public function hashToFieldValue($fieldValue, array $context = array())
18
    {
19 1
        return new CheckboxValue(($fieldValue == 1) ? true : false);
20
    }
21
}
22