for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
Author: Irfa Ardiansyah <[email protected]>
*/
namespace Irfa\SerialNumber\Core;
class ConfigInit
{
protected $length;
protected $segment;
protected $seperator;
protected $charset;
protected function runConfig($config_array=null)
if(empty($config_array))
$this->setConfig();
} else {
$this->directConfig($config_array);
}
private function setConfig()
if (function_exists('config') and function_exists('app')) {//Load Config For Laravel
if(!empty(config('irfa.serial_number')))
$this->laravelConfig();
} else{
$this->generalConfig();
} else{//Load Config for Non-Laravel
private function laravelConfig()
$this->length = config('irfa.serial_number.length');
config
If this is a false-positive, you can also ignore this issue in your code via the ignore-call annotation
ignore-call
$this->length = /** @scrutinizer ignore-call */ config('irfa.serial_number.length');
$this->segment = config('irfa.serial_number.segment');
$this->seperator = config('irfa.serial_number.seperator');
$this->charset = config('irfa.serial_number.charset');
private function generalConfig()
require dirname(__DIR__, 2)."/config/config.php";
$this->length = $config['length'];
$config
$this->segment = $config['segment'];
$this->seperator = $config['seperator'];
$this->charset = $config['charset'];
private function directConfig($arr)
$this->length = isset($arr['length']) ? $arr['length']:$config['length'];
$this->segment = isset($arr['segment']) ? $arr['segment']:$config['segment'];
$this->seperator = isset($arr['seperator']) ? $arr['seperator']:$config['seperator'];
$this->charset = isset($arr['charset']) ? $arr['charset']:$config['charset'];