Completed
Push — master ( 319aa4...523298 )
by smiley
04:24
created

DBResultRow::__get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
/**
3
 * Class DBResultRow
4
 *
5
 * @filesource   DBResultRow.php
6
 * @created      23.05.2017
7
 * @package      chillerlan\Database
8
 * @author       Smiley <[email protected]>
9
 * @copyright    2017 Smiley
10
 * @license      MIT
11
 */
12
13
namespace chillerlan\Database;
14
15
/**
16
 *
17
 * __call() -> fieldname($func)
18
 */
19
class DBResultRow extends DBResult{
20
21
	/**
22
	 * @param string $name
23
	 * @param array  $arguments
24
	 *
25
	 * @return mixed|null
26
	 */
27
	public function __call(string $name, array $arguments){
28
29
		if(isset($this->array[$name])){
30
31
			if(isset($arguments[0]) && is_callable($arguments[0])){
32
				return call_user_func_array($arguments[0], [$this->array[$name]]);
33
			}
34
35
			return $this->array[$name];
36
		}
37
38
		return null;
39
	}
40
41
	/**
42
	 * @param string $name
43
	 *
44
	 * @return mixed|null
45
	 */
46
	public function __get(string $name) {
47
48
		if(isset($this->array[$name])){
49
			return $this->array[$name];
50
		}
51
52
		return null;
53
	}
54
55
	/**
56
	 * @link http://api.prototypejs.org/language/Enumerable/prototype/pluck/
57
	 *
58
	 * @param string $property
59
	 *
60
	 * @return array
61
	 */
62
	public function pluck(string $property):array {
63
		return [];
64
	}
65
66
	/**
67
	 * @param int   $offset
68
	 * @param array $value
69
	 *
70
	 * @return void
71
	 */
72 View Code Duplication
	public function offsetSet($offset, $value){
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...
73
74
		if(is_null($offset)){
75
			$this->array[] = $value;
76
		}
77
		else{
78
			$this->array[$offset] = $value;
79
		}
80
81
	}
82
83
}
84