singelton constructor

the $param['type'] is for the factory to create the correct Config

@param array $param

@return AbstractConfig
766584
public static function getInstance($param = null)
    {
        if (self::$instance === null) {
            if (isset($param['type'])) {
                $type = $param['type'];
                unset($param['type']);
            } else {
                throw new \LogicException('Config Type was not specified in the param array $param[\'type\']');
            }

            self::$instance = ConfigFactory::make($type, $param);
        }

        // return singelton instance
        return self::$instance;
    }
1169936
public static function getInstance(array $param = array())
    {
        if (!(self::$instance instanceof Handler)) {
            // construct the object
            self::$instance = new self();
        }

        if ($param)  {
            return self::$instance->{$param};
        }


        // return the object
        return self::$instance;
    }
540523
protected function createObject($abstract=null, array $parameters=[])
    {

        $abstract = $this->factoryAbstract($abstract);

        if (!$this->_customFactory) {
            return $this->createWithoutFactory($abstract, $parameters);
        }

        return Lambda::callFast($this->_customFactory, [$abstract, $parameters]);
    }
1114698
protected function _defaultInput($param)
    {
        $input = $param->formInputConfig();
        $name = $param->config('name');
        $input += [
            'type' => 'text',
            'required' => false,
            'label' => Inflector::humanize(preg_replace('/_id$/', '', $name)),
        ];
        if (!$param->visible()) {
            $input['type'] = 'hidden';
        }

        return $input;
    }
748150
private function locateParam($params, $param)
    {
        $value = null;
        $keys = explode('.', $param);
        for ($i = 0, $mx = count($keys); $i < $mx; $i++) {
            $key = $keys[$i];
            if (isset($params[$key])) {
                $value = $params[$key];
                if ((($i + 1) < $mx) && is_array($value)) {
                    return $this->locateParam($value, implode('.', array_slice($keys, $i)));
                }
            }
        }
        return $value;
    }
1080580
public static function create(array $params = [])
    {
        $assembler = new static();
        if (!empty($params)) {
            array_walk($params, function($v, $k) use ($assembler) {
                $assembler->$k(function() use($v) {return $v;});
            });
            $assembler->assemble();
        }

        return $assembler;
    }
1065496
private function paramVarsAlign($param, $previousParam)
	{
		$paramStringLength         = strlen($param['type']) + $param['type_space'];
		$previousParamStringLength = strlen($previousParam['type']) + $previousParam['type_space'];

		return $paramStringLength === $previousParamStringLength;
	}
1370532
public function encodeParameter($type, $param)
    {
        if (!is_string($type)) {
            throw new InvalidArgumentException('The type to encodeParameter must be string.');
        }
        return $this->encodeParameters([$type], [$param]);
    }
332567
protected function injectVars($param)
    {
        if (!is_string($param) || !preg_match_all('/\{([^\}\{]+)\}/', $param, $matches)) {
            return $this->getCorrectType($param);
        }

        foreach ($matches[1] as $index => $match) {
            $key = $this->prepareVarName($match);

            if (!isset($this->vars[$key])) {
                continue;
            }

            $param = str_replace(sprintf('{%s}', $match), $this->vars[$key], $param);
        }

        return $this->getCorrectType($param);
    }
1111434
public static function make($type, $param = null)
    {
        if (!$type) {
            throw new \LogicException("The Config Type has to be specified ... \$type is empty");
        }

        $className = (string)__NAMESPACE__ . '\\' . (string)ucfirst($type);

        if (!class_exists($className, true)) {
            throw new \LogicException("The Config class has to be implemented and accessible ... $className is not found");
        }

        return new $className($param);
    }
1233507
public function setParameters(array $params): self
    {
        foreach ($params as $key => $value) {
            $this->parameters[$key] = $value;
        }
        return $this;
    }
903526
public static function getInstance($param = null): Cache
    {
        if (!self::$instance instanceof self) {
            $param = json_decode(json_encode($param), true);

            self::$instance = new Cache(
                $param[self::IDX_ADAPTER_NAME],
                $param[self::IDX_PARAMETERS] ?? []
            );
        }

        return self::$instance;
    }
214809
public function call($params = null)
    {
        $method = $this->method;

        if (!empty($this->constructor_arguments)) {
            $instance = new $this->class($this->constructor_arguments);
        } else {
            $instance = new $this->class();
        }
        if (!is_null($params)) {
            return $instance->$method($params);
        }
        return $instance->$method();
    }
652022
public function call($param = null)
    {
        // get the class within the correct namespace
        // initiate object
        $object = $this->prepareObject(new $this->class());

        $return    = new \SplFixedArray(2);
        $return[1] = $object;

        if (!empty($this->method)) {
            if (!empty($param) && !empty($this->param)) {
                $return[0] = $object->{$this->method}(array_merge((array)$this->param, (array)$param));

                return $return;
            }
            $return[0] = $object->{$this->method}();

            return $return;
        }

        return $return;
    }
342698
final protected function getValueFromConfig(string $param)
  {
    $value = null;
    $config = self::$suiteConfig;

    preg_match_all(self::$regEx['config'], $param, $args, PREG_PATTERN_ORDER);
    foreach ($args[1] as $arg) {
      if (array_key_exists($arg, $config)) {
        $value = $config[$arg];
        if (is_array($value)) {
          $config = $value;
        } else {
          break;
        }
      }
    }
    return $value;
  }
1023685
public function setParam($param, array $binds = [])
    {
        $this->param = preg_replace_callback('/\{\w+\}/', function () use (&$binds) {
            return array_shift($binds);
        }, trim($param, '/'));

        return $this;
    }
916459
private function paramCommentsAlign($param, $previousParam)
	{
		$paramLength = strlen($param['type']) + $param['type_space'] + strlen($param['var']) + $param['var_space'];
		$prevLength  = strlen($previousParam['type']) + $previousParam['type_space'] + strlen($previousParam['var']) + $previousParam['var_space'];

		return $paramLength === $prevLength;
	}