You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
payment/app/Helper/Efps/Result.php

52 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Helper\Efps;
class Result
{
private $data;
public function __construct($data)
{
$this->data = $data;
}
public function isSuccess()
{
return $this->data['returnCode'] == '0000';
}
public function get($key, $default = null)
{
return $this->data[$key] ?? $default;
}
public function getCode()
{
return $this->data['returnCode'];
}
public function getMessage()
{
return $this->data['returnMsg'];
}
public function getData(array $fields = null)
{
$returnData = [];
if (is_array($fields)) {
foreach ($fields as $field) {
$returnData[$field] = $this->data[$field] ?? null;
}
} else {
$returnData = $this->data;
}
unset($returnData['returnCode']);
unset($returnData['returnMsg']);
unset($returnData['nonceStr']);
unset($returnData['customerCode']);
return $returnData;
}
}