Gc\Core\Object::unsetData PHP Method

unsetData() public method

$key can be a string only. Array will be ignored.
public unsetData ( string $key = null ) : Object
$key string Key
return Object
    public function unsetData($key = null)
    {
        if (is_null($key)) {
            $this->data = array();
        } else {
            unset($this->data[$key]);
        }
        return $this;
    }

Usage Example

Beispiel #1
0
 /**
  * Test
  *
  * @return void
  */
 public function testUnsetAllData()
 {
     $this->object->setData('k', 'v');
     $this->object->unsetData();
     $this->assertNull($this->object->getData('k'));
 }