Created
May 18, 2017 15:57
-
-
Save gpfiel/476997cdd728817670bd204a1f27ac89 to your computer and use it in GitHub Desktop.
Miamed Refactor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Com\Company\System; | |
use \Com\Company\Interfaces; | |
class VerifyHelper | |
{ | |
/** | |
* @var Interfaces\UserValidationServiceImpl $us | |
*/ | |
private $us; | |
/** | |
* @var Interfaces\ParamServiceImpl $serviceImpl | |
*/ | |
private $serviceImpl; | |
/** | |
* VerifyHelper constructor. | |
*/ | |
public function __construct() | |
{ | |
$this->us = \DI::get("userValidation"); | |
$this->serviceImpl = \DI::get("paramService"); | |
} | |
/** | |
* Performs an action. | |
* @param $str | |
* @return string | |
*/ | |
public function performAction($str) | |
{ | |
if (!is_string($str) || !strlen($str)) { | |
return "INVALID_PARAMETER"; | |
} | |
$now = (new \DateTime("now", new \DateTimeZone("Europe/London")))->format("Y-m-d"); | |
$split = explode(';', $str); | |
$client_id = $split[0]; | |
$customer_code = $split[1] ?? null; | |
$sb = "<xml><client_id>$client_id</client_id>"; | |
if ($this->isNew() && $customer_code) { | |
$sb .= "<customer_code>$customer_code</customer_code>"; | |
} | |
$sb .= "<check_date>$now</check_date>"; | |
$sb .= "</xml>"; | |
return $this->us->validate($sb); | |
} | |
/** | |
* @return bool | |
*/ | |
public function isNew() | |
{ | |
return $this->serviceImpl->getParam("NEW_CLIENT_MODEL") == "YES"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment