Skip to content

Instantly share code, notes, and snippets.

@kobus1998
Created June 4, 2019 07:51
Show Gist options
  • Save kobus1998/b6e78a88c9bc09ef50f177812c55300c to your computer and use it in GitHub Desktop.
Save kobus1998/b6e78a88c9bc09ef50f177812c55300c to your computer and use it in GitHub Desktop.
Simple Entity class
<?php
class Entity
{
protected $touched = false;
public function __construct($aData)
{
foreach($aData as $key => $val) {
$this->{$key} = $val;
}
}
public function has($key)
{
return isset($this->{$key}) && $this->{$key} !== null;
}
public function get($key)
{
return $this->{$key};
}
public function set($key, $val)
{
$this->touched = true;
$this->{$key} = $val;
return $this;
}
public function isTouched()
{
return $this->touched;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment