Passed
Push — wip-public-release ( a47743...14cdbd )
by Bogdan
02:52
created

RawExtractor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 70 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 14
loc 20
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A extract() 14 14 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php declare(strict_types=1);
2
3
/*
4
 * This file is part of the pinepain/js-sandbox PHP library.
5
 *
6
 * Copyright (c) 2016-2017 Bogdan Padalko <[email protected]>
7
 *
8
 * Licensed under the MIT license: http://opensource.org/licenses/MIT
9
 *
10
 * For the full copyright and license information, please view the
11
 * LICENSE file that was distributed with this source or visit
12
 * http://opensource.org/licenses/MIT
13
 */
14
15
16
namespace Pinepain\JsSandbox\Extractors\PlainExtractors;
17
18
19
use Pinepain\JsSandbox\Extractors\Definition\PlainExtractorDefinitionInterface;
20
use Pinepain\JsSandbox\Extractors\ExtractorException;
21
use Pinepain\JsSandbox\Extractors\ExtractorInterface;
22
use V8\Context;
23
use V8\Value;
24
25
26
class RawExtractor implements PlainExtractorInterface
27
{
28
    /**
29
     * {@inheritdoc}
30
     */
31 View Code Duplication
    public function extract(Context $context, Value $value, PlainExtractorDefinitionInterface $definition, ExtractorInterface $extractor)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
32
    {
33
        if ($definition->getNext()) {
34
            // we have a type constraint on raw value here, so regards that we return raw value,
35
            // we will try to extract it just to ensure constrain validity
36
            try {
37
                $extractor->extract($context, $value, $definition->getNext());
38
            } catch (ExtractorException $e) {
39
                throw new ExtractorException('Raw value constraint failed: ' . $e->getMessage());
40
            }
41
        }
42
43
        return $value;
44
    }
45
}
46