Gc\Core\Object::setData PHP Method

setData() public method

$key can be string or array. If $key is string, the attribute value will be overwritten by $value If $key is an array, it will overwrite all the data in the object.
public setData ( string | array $key, mixed $value = null ) : Object
$key string | array Key
$value mixed Value
return Object
    public function setData($key, $value = null)
    {
        if (is_array($key)) {
            $this->data = $key;
        } else {
            $this->data[$key] = $value;
        }
        return $this;
    }

Usage Example

Beispiel #1
0
 /**
  * Test
  *
  * @return void
  */
 public function testOffsetGet()
 {
     $this->object->setData('k', 'v');
     $this->assertEquals('v', $this->object->offsetGet('k'));
 }