class App{
protected $db = 'database';
protected $data = [];
public function setData(array $data)
{
$this->data = $data;
}
}
class Product extends App
{
public function getId()
{
return array_key_exists('id', $this->data)
? $this->data['id']
: null;
}
}
$a = new Product();
$a->setData(['id' => 1]);
var_dump($a->getId());