mageekguy\atoum\asserters\phpArray::setWith PHP Method

setWith() public method

public setWith ( $value, $checkType = true )
    public function setWith($value, $checkType = true)
    {
        $innerAsserter = $this->innerAsserter;
        if ($innerAsserter !== null) {
            $this->reset();
            return $innerAsserter->setWith($value);
        } else {
            parent::setWith($value);
            if ($this->analyzer->isArray($this->value) === true || $checkType === false) {
                $this->pass();
            } else {
                $this->fail($this->_('%s is not an array', $this));
            }
            return $this;
        }
    }

Usage Example

示例#1
0
 public function setWith($value)
 {
     parent::setWith($value, false);
     $fail = false;
     $this->adapter->set_error_handler(function () use(&$fail) {
         $fail = true;
     });
     switch (true) {
         case $this->value instanceof \Iterator:
             $value = iterator_to_array($this->value);
             break;
         case $this->getAnalyzer()->isString($value):
             $value = $this->adapter->str_split($value);
             $fail = $value === false;
             break;
         default:
             $value = (array) $value;
     }
     $this->adapter->restore_error_handler();
     if ($fail) {
         $this->fail($this->getLocale()->_('%s could not be converted to array', $this->getTypeOf($this->value)));
     }
     $this->value = $value;
     return $this->pass();
 }
All Usage Examples Of mageekguy\atoum\asserters\phpArray::setWith