Created
June 4, 2019 07:51
-
-
Save kobus1998/b6e78a88c9bc09ef50f177812c55300c to your computer and use it in GitHub Desktop.
Simple Entity class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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