GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

CheckboxFieldHandler   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 28
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A supports() 0 4 1
A toString() 0 4 1
A getLegacyValue() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Netgen\InformationCollection\Core\Persistence\FieldHandler\Custom;
6
7
use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition;
8
use eZ\Publish\Core\FieldType\Checkbox\Value as CheckboxValue;
9
use eZ\Publish\Core\FieldType\Value;
10
use Netgen\InformationCollection\API\FieldHandler\CustomLegacyFieldHandlerInterface;
11
use Netgen\InformationCollection\API\Value\Legacy\FieldValue;
12
13
class CheckboxFieldHandler implements CustomLegacyFieldHandlerInterface
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18
    public function supports(Value $value): bool
19
    {
20
        return $value instanceof CheckboxValue;
21
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function toString(Value $value, FieldDefinition $fieldDefinition): string
27
    {
28
        return (string) $value;
29
    }
30
31
    /**
32
     * @param \eZ\Publish\Core\FieldType\Checkbox\Value $value
33
     *
34
     * @return \Netgen\InformationCollection\API\Value\Legacy\FieldValue
35
     */
36
    public function getLegacyValue(Value $value, FieldDefinition $fieldDefinition): FieldValue
37
    {
38
        return FieldValue::withIntValue($fieldDefinition->id, (int) $value->bool);
39
    }
40
}
41