Completed
Pull Request — v0.10 (#630)
by Tautrimas
93:19
created

AbstractValue   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 28
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 3
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
/**
15
 * Abstract annotations used for handling value.
16
 */
17
abstract class AbstractValue
18
{
19
    /**
20
     * @var array
21
     */
22
    public $value;
23
24
    /**
25
     * Constructor.
26
     *
27
     * @param array $values
28
     *
29
     * @throws \InvalidArgumentException
30
     */
31
    public function __construct(array $values)
32
    {
33
        if (is_string($values['value'])) {
34
            $this->value = [$values['value']];
35
        } elseif (is_array($values['value'])) {
36
            $this->value = $values['value'];
37
        } else {
38
            throw new \InvalidArgumentException(
39
                'Annotation `' . get_class($this) . '` unexpected type given. Expected string or array, given `'
40
                . gettype($values['value']) . '`'
41
            );
42
        }
43
    }
44
}
45