Code Duplication    Length = 18-18 lines in 3 locations

src/Extractors/PlainExtractors/BoolExtractor.php 1 location

@@ 28-45 (lines=18) @@
25
use V8\Value;
26
27
28
class BoolExtractor implements PlainExtractorInterface
29
{
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function extract(Context $context, Value $value, PlainExtractorDefinitionInterface $definition, ExtractorInterface $extractor)
34
    {
35
        if ($value instanceof BooleanValue) {
36
            return $value->value();
37
        }
38
39
        if ($value instanceof BooleanObject) {
40
            return $value->valueOf();
41
        }
42
43
        throw new ExtractorException('Value must be of the type bool, ' . $value->typeOf()->value() . ' given');
44
    }
45
}
46

src/Extractors/PlainExtractors/NumberExtractor.php 1 location

@@ 28-45 (lines=18) @@
25
use V8\Value;
26
27
28
class NumberExtractor implements PlainExtractorInterface
29
{
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function extract(Context $context, Value $value, PlainExtractorDefinitionInterface $definition, ExtractorInterface $extractor)
34
    {
35
        if ($value instanceof NumberValue) {
36
            return $value->value();
37
        }
38
39
        if ($value instanceof NumberObject) {
40
            return $value->valueOf();
41
        }
42
43
        throw new ExtractorException('Value must be of the type number, ' . $value->typeOf()->value() . ' given');
44
    }
45
}
46

src/Extractors/PlainExtractors/StringExtractor.php 1 location

@@ 28-45 (lines=18) @@
25
use V8\Value;
26
27
28
class StringExtractor implements PlainExtractorInterface
29
{
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function extract(Context $context, Value $value, PlainExtractorDefinitionInterface $definition, ExtractorInterface $extractor)
34
    {
35
        if ($value instanceof StringValue) {
36
            return $value->value();
37
        }
38
39
        if ($value instanceof StringObject) {
40
            return $value->valueOf()->value();
41
        }
42
43
        throw new ExtractorException('Value must be of the type string, ' . $value->typeOf()->value() . ' given');
44
    }
45
}
46