In my program I read values from a configuration array.First I just used magic constants like this:private $config = array(    'ignoreWarnings' => true,);private function ignoreWarnings(){    if (is_bool($this->config['ignoreWarnings']) === false) {        throw new Exception(sprintf('Invalid %s config value.', 'ignoreWarnings'));    }    /* @var $ignoreWarnings bool */    $ignoreWarnings = $this->config['ignoreWarnings'];    return $ignoreWarnings;   }But then I moved the config key name to a class constantprivate $config = array(    self::IGNORE_WARNINGS_CONFIG_KEY => true,);private function ignoreWarnings(){    if (is_bool($this->config[self::IGNORE_WARNINGS_CONFIG_KEY]) === false) {        throw new Exception(sprintf('Invalid %s config value.', self::IGNORE_WARNINGS_CONFIG_KEY));    }    /* @var $ignoreWarnings bool */    $ignoreWarnings = $this->config[self::IGNORE_WARNINGS_CONFIG_KEY];    return $ignoreWarnings;}Pros:No code duplicationNo magic constantsImpossible to make a typoLess error-proneEasier to make changesCons:?Which of the options would you stick to and why?P.S. Custom config is injected via constructor like thispublic function __construct(array $config = array()){    $this->config = array_merge($this->config, $config);}
Code duplication vs wordiness
php;array;comparative review;constants
i think the first one if condition is good , because the second code , have a constant value ,this could make longer to read from the memory good luck bro 