Completed
Pull Request — 1.1 (#646)
by
unknown
18:44
created

Embedded   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 61
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 1
dl 61
loc 61
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A dump() 22 22 2

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
2
3
/*
4
 * This file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace ONGR\ElasticsearchBundle\Annotation;
13
14
use ONGR\ElasticsearchBundle\Mapping\Caser;
15
16
/**
17
 * Annotation for property which points to inner object.
18
 *
19
 * @Annotation
20
 * @Target("PROPERTY")
21
 */
22 View Code Duplication
final class Embedded
0 ignored issues
show
Duplication introduced by
This class 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...
23
{
24
    /**
25
     * Inner object class name.
26
     *
27
     * @var string Object name to map
28
     *
29
     * @Doctrine\Common\Annotations\Annotation\Required
30
     */
31
    public $class;
32
33
    /**
34
     * Name of the type field. Defaults to normalized property name.
35
     *
36
     * @var string
37
     */
38
    public $name;
39
40
    /**
41
     * Defines if related value will store a single object or an array of objects
42
     *
43
     * If this value is set to true, in the result ObjectIterator will be provided,
44
     * otherwise you will get single object.
45
     *
46
     * @var bool Object or ObjectIterator
47
     */
48
    public $multiple;
49
50
    /**
51
     * In this field you can define options.
52
     *
53
     * @var array
54
     */
55
    public $options;
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public function dump(array $exclude = [])
61
    {
62
        $array = array_diff_key(
63
            array_filter(
64
                get_object_vars($this),
65
                function ($value) {
66
                    return $value || is_bool($value);
67
                }
68
            ),
69
            array_flip(array_merge(['class', 'name', 'multiple'], $exclude))
70
        );
71
72
        return array_combine(
73
            array_map(
74
                function ($key) {
75
                    return Caser::snake($key);
76
                },
77
                array_keys($array)
78
            ),
79
            array_values($array)
80
        );
81
    }
82
}
83