Find   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 93.75%

Importance

Changes 0
Metric Value
dl 0
loc 51
c 0
b 0
f 0
wmc 8
lcom 1
cbo 2
ccs 15
cts 16
cp 0.9375
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A jsonNotation() 0 4 1
A nativeArray() 0 4 1
A voArray() 0 10 3
A keyFromArrayValue() 0 8 3
1
<?php
2
3
namespace BestServedCold\PhalueObjects\VOArray;
4
5
use BestServedCold\PhalueObjects\Format\Json\Notation;
6
use BestServedCold\PhalueObjects\VOArray;
7
8
/**
9
 * Class Find
10
 *
11
 * @package BestServedCold\PhalueObjects\VOArray
12
 */
13
class Find extends VOArray
14
{
15
    /**
16
     * @param  Notation $notation
17
     * @return bool
18
     */
19 1
    public function jsonNotation(Notation $notation)
0 ignored issues
show
Coding Style introduced by
function jsonNotation() does not seem to conform to the naming convention (^(?:is|has|should|may|supports)).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
20
    {
21 1
        return $this->voArray($notation->toVOArray());
22
    }
23
24
    /**
25
     * @param  array $array
26
     * @return bool|mixed
27
     */
28 1
    public function nativeArray(array $array)
29
    {
30 1
        return $this->voArray(VOArray::fromArray($array));
31
    }
32
33
    /**
34
     * Iterates through an array of values and finds a key.  If it makes it to the final value,
35
     * it returns what ever value matches that key.
36
     *
37
     * @param  VOArray    $arrayValueObject
38
     * @return bool|mixed
39
     */
40 2
    public function voArray(VOArray $arrayValueObject)
41
    {
42 2
        if ($key = VOArray::fromArray($this->getValue())->getKey($arrayValueObject->current())) {
43 2
            return $arrayValueObject->isLast() ? $key
44 2
                : static::fromArray($key)
45 2
                    ->voArray($arrayValueObject->dropFirst());
46
        }
47
48 2
        return false;
49
    }
50
51
    /**
52
     * @param  $arrayValue
53
     * @return int|string
54
     */
55 2
    public function keyFromArrayValue($arrayValue)
56
    {
57 2
        foreach ($this->getValue() as $key => $value) {
58 2
            if (in_array(strtolower($arrayValue), array_map('strtolower', $value))) {
59 2
                return $key;
60
            }
61 2
        }
62
    }
63
}
64