I am writing a library to access a web service and perform several
transaction with this web service:
class ErpInterfaceTransaction
{
private $erpinterface,
$transactionid;
public function __construct($erpinterface)
{
$this->erpinterface = $erpinterface;
$this->transactionid = uniqid();
}
public function place_order()
{
file_get_contents('http://gateway/process.php?token='.$this-
>erpinterface->token.'&action=place_order');}
}
class ErpInterface
{
public $token;
public function begin_transaction()
{
return new ErpInterfaceTransaction($this);
}
}
Should I make the ErpInterfaceTransaction class extend the
ErpInterface class?
I need to make $token public because the transactions need it (see
"$this->erpinterface->token"). Can I avoid this?
What is the preferred design pattern for such a construction?
Regards,
André