mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-21 21:43:57 +00:00
112 lines
2.2 KiB
PHP
112 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Vouchers\DataTransferObjects;
|
|
|
|
use App\Classes\General\Interfaces\DataTransferObject;
|
|
use DateTime;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class VoucherObject implements DataTransferObject
|
|
{
|
|
/** @var string */
|
|
private $code;
|
|
|
|
/** @var string|null */
|
|
private $name;
|
|
|
|
/** @var string|null */
|
|
private $type;
|
|
|
|
/** @var float|null */
|
|
private $value;
|
|
|
|
/** @var string|null */
|
|
private $startDate;
|
|
|
|
/** @var string|null */
|
|
private $endDate;
|
|
|
|
/**
|
|
* VoucherObject constructor.
|
|
* @param string $code
|
|
* @param string $name
|
|
* @param string $type
|
|
* @param float $value
|
|
* @param string $startDate
|
|
* @param string $endDate
|
|
*/
|
|
public function __construct(string $code, ?string $name, ?string $type, ?float $value, ?string $startDate = '', ?string $endDate = '')
|
|
{
|
|
$this->code = $code;
|
|
$this->name = $name;
|
|
$this->type = $type;
|
|
$this->value = $value;
|
|
$this->startDate = $startDate;
|
|
$this->endDate = $endDate;
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getCode(): string
|
|
{
|
|
return $this->code;
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getName(): ?string
|
|
{
|
|
return $this->name;
|
|
}
|
|
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getType(): ?string
|
|
{
|
|
return $this->type;
|
|
}
|
|
|
|
|
|
/**
|
|
* @return float
|
|
*/
|
|
public function getValue(): ?float
|
|
{
|
|
return $this->value;
|
|
}
|
|
|
|
/**
|
|
* @return DateTime
|
|
*/
|
|
public function getStartDate(): ?DateTime
|
|
{
|
|
try {
|
|
if(!$this->startDate) return null;
|
|
$dateTime = new DateTime($this->startDate);
|
|
return $dateTime;
|
|
} catch (\Exception $e) {
|
|
Log::error($e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return DateTime
|
|
*/
|
|
public function getEndDate(): ?DateTime
|
|
{
|
|
try {
|
|
if(!$this->endDate) return null;
|
|
$dateTime = new DateTime($this->endDate);
|
|
return $dateTime;
|
|
} catch (\Exception $e) {
|
|
Log::error($e);
|
|
return null;
|
|
}
|
|
}
|
|
}
|