public function testTrim() { $target = ['a' => 1, 'b' => null, 'c' => ['d' => 1, 'e' => [], 'f' => ['g' => null], 'h' => ['i' => ''], 'j' => ['k' => [], 'l' => 1]]]; $this->assertSame(['a' => 1, 'c' => ['d' => 1, 'j' => ['l' => 1]]], Complex::trim($target)); $target = ['a' => [null, 1, '', 'a']]; $this->assertSame(['a' => [1, 'a']], Complex::trim($target)); }
public function unpack(\Owl\DataMapper\Data $data, array $options = null) { $record = parent::unpack($data, $options); if ($data->isFresh()) { $record = Type\Complex::trim($record); } return $record; }
/** * @param string $key * @param array|string $path * @return mixed|false */ public function getIn($key, $path) { $target = $this->get($key); $path = (array) $path; if (!is_array($target)) { throw new Exception\UnexpectedPropertyValueException(get_class($this) . ": Property {$key} is not complex type"); } return Type\Complex::getIn($target, $path); }
public function store($value, array $attribute) { $value = parent::store($value, $attribute); return $value ? self::encode($value) : null; }