for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Maphper;
class MultiPk implements \ArrayAccess {
private $parent;
private $primaryKey;
private $lookup;
private $mapper;
public function __construct(Maphper $mapper, $lookup, array $primaryKey, MultiPk $parent = null) {
$this->parent = $parent;
$this->primaryKey = $primaryKey;
$this->lookup = $lookup;
$depth = $this->getDepth();
$this->mapper = $mapper->filter([$primaryKey[$depth] => $lookup]);
filter()
Maphper\Maphper
__call
If this is a false-positive, you can also ignore this issue in your code via the ignore-call annotation
ignore-call
/** @scrutinizer ignore-call */
}
private function getDepth() {
$depth = 0;
$obj = $this;
while ($obj->parent != null) {
$depth++;
$obj = $obj->parent;
return $depth;
public function offsetGet($key) {
$depth = $this->getDepth()+1;
if (count($this->primaryKey)-1 == $depth) return $this->mapper->filter([$this->primaryKey[$depth] => $key])->item(0);
else return new MultiPk($this->mapper, $key, $this->primaryKey, $this);
public function offsetSet($key, $value) {
$keys = $this->primaryKey;
$key1 = array_pop($keys);
$value->$key1 = $key;
while ($key = array_pop($keys)) {
$value->$key = $obj->lookup;
$this->mapper[] = $value;
public function offsetUnset($key) {
$this->mapper->filter([ array_pop($keys) => $key])->delete();
public function offsetExists($key) {
return $this->offsetGet($key);
return $this->offsetGet($key)
Maphper\MultiPk
ArrayAccess::offsetExists()
boolean