Skip to content

Instantly share code, notes, and snippets.

@gpfiel
Created May 18, 2017 15:57
Show Gist options
  • Save gpfiel/476997cdd728817670bd204a1f27ac89 to your computer and use it in GitHub Desktop.
Save gpfiel/476997cdd728817670bd204a1f27ac89 to your computer and use it in GitHub Desktop.
Miamed Refactor
<?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