mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-29 11:10:19 +02:00
36 lines
654 B
PHP
36 lines
654 B
PHP
<?php
|
|
|
|
namespace DesignPatterns\Behavioral\State;
|
|
|
|
class CreateOrder implements Order
|
|
{
|
|
/**
|
|
* @var array
|
|
*/
|
|
private $details;
|
|
|
|
/**
|
|
* @param array $details
|
|
*/
|
|
public function __construct(array $details)
|
|
{
|
|
$this->details = $details;
|
|
}
|
|
|
|
public function shipOrder()
|
|
{
|
|
$this->details['status'] = 'shipping';
|
|
$this->details['updatedTime'] = time();
|
|
}
|
|
|
|
public function completeOrder()
|
|
{
|
|
throw new \Exception('Can not complete the order which status is created');
|
|
}
|
|
|
|
public function getStatus(): string
|
|
{
|
|
return $this->details['status'];
|
|
}
|
|
}
|