From e1fa0ececb17d2f3aa0bd29c00379d04eeecbab7 Mon Sep 17 00:00:00 2001 From: Timoffei Bubigo Date: Wed, 27 Jan 2021 16:43:36 +0300 Subject: [PATCH] Add null variables --- app/Console/Commands/HRCCommand.php | 30 ++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/app/Console/Commands/HRCCommand.php b/app/Console/Commands/HRCCommand.php index 9519dc8..ded290f 100644 --- a/app/Console/Commands/HRCCommand.php +++ b/app/Console/Commands/HRCCommand.php @@ -30,23 +30,29 @@ class HRCCommand extends Command private function prepareInput() { - $source_file = CORE_PATH . '/temp/' . $this->argument('source'); - $data = parse_ini_file($source_file); + if($this->argument('source') != 'null') { + $source_file = CORE_PATH . '/temp/' . $this->argument('source'); + $data = parse_ini_file($source_file); - if(isset($data['raw_result'])) { - unset($data['raw_result']); + if (isset($data['raw_result'])) { + unset($data['raw_result']); + } + + return $data; } - return $data; + return []; } private function prepareOutput() { - $source_file = CORE_PATH . '/temp/' . $this->argument('source'); - $data = parse_ini_file($source_file); + if($this->argument('source') != 'null') { + $source_file = CORE_PATH . '/temp/' . $this->argument('source'); + $data = parse_ini_file($source_file); - if(isset($data['raw_result'])) { - return json_decode(base64_decode($data['raw_result']), true); + if (isset($data['raw_result'])) { + return json_decode(base64_decode($data['raw_result']), true); + } } return null; @@ -54,8 +60,10 @@ class HRCCommand extends Command public function save($result) { - $result_file = CORE_PATH . '/temp/' . $this->argument('result'); - file_put_contents($result_file, json_encode($result)); + if($this->argument('result') != 'null') { + $result_file = CORE_PATH . '/temp/' . $this->argument('result'); + file_put_contents($result_file, json_encode($result)); + } } private function getCoreConfig($name, $default = null)