chillerlan /
php-database
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Class ResultRow |
||
| 4 | * |
||
| 5 | * @filesource ResultRow.php |
||
| 6 | * @created 28.06.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 | * @property mixed[] $array |
||
| 17 | */ |
||
| 18 | class ResultRow extends Result{ |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @param string $name |
||
| 22 | * @param array $arguments |
||
| 23 | * |
||
| 24 | * @return mixed|null |
||
| 25 | */ |
||
| 26 | public function __call(string $name, array $arguments){ |
||
| 27 | $value = $this->array[$name] ?? null; |
||
| 28 | |||
| 29 | if($value !== null){ |
||
| 30 | $func = $arguments[0] ?? null; |
||
| 31 | |||
| 32 | if(is_callable($func)){ |
||
| 33 | return call_user_func_array($func, [$value]); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 34 | } |
||
| 35 | |||
| 36 | } |
||
| 37 | |||
| 38 | return $value; |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @inheritdoc |
||
| 43 | */ |
||
| 44 | public function __get(string $name){ |
||
| 45 | return $this->array[$name] ?? null; |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @inheritdoc |
||
| 50 | */ |
||
| 51 | public function __toArray():array{ |
||
| 52 | return $this->__EnumerableToArray(); |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @inheritdoc |
||
| 57 | */ |
||
| 58 | public function offsetSet($offset, $value):void{ |
||
| 59 | |||
| 60 | if($this->sourceEncoding !== null && is_string($value)){ |
||
| 61 | $value = mb_convert_encoding($value, $this->destEncoding, $this->sourceEncoding); |
||
| 62 | } |
||
| 63 | |||
| 64 | $offset !== null |
||
| 65 | ? $this->array[$offset] = $value |
||
| 66 | : $this->array[] = $value; |
||
| 67 | |||
| 68 | } |
||
| 69 | |||
| 70 | } |
||
| 71 |