Completed
Push — master ( a7db3c...a6cff5 )
by Afshin
02:21
created

AbstractSession::setArr()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 9
nc 3
nop 2
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: afshin
5
 * Date: 12/8/17
6
 * Time: 11:28 PM
7
 */
8
9
namespace Core\Interfaces;
10
11
12
class AbstractSession
13
{
14
15 View Code Duplication
     public function getRecursiveSessionKey($data , $keyArr){
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...
16
        $arrayFound  = isset($data[$keyArr[0]]) ? $data[$keyArr[0]] : '';
17
        if($arrayFound){
18
            unset($keyArr[0]);
19
            $keyArr = array_values($keyArr);
20
            if(isset($keyArr[0])){
21
                return $this->getRecursiveSessionKey($arrayFound,$keyArr);
22
            }
23
        }
24
        return $arrayFound ;
25
    }
26
27
28
    public static function setArr($key, $value)
29
    {
30
        foreach (explode('.', $key) as $keyName) {
31
            if (false === isset($source)) {
32
                $source    = array();
33
                $sourceRef = &$source;
34
            }
35
            $keyName = trim($keyName);
36
            $sourceRef  = &$sourceRef[$keyName];
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $sourceRef seems to be defined later in this foreach loop on line 33. Are you sure it is defined here?
Loading history...
37
        }
38
        $sourceRef = $value;
39
        unset($sourceRef);
40
        return $source;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $source seems to be defined by a foreach iteration on line 30. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
41
    }
42
43
}