/** * getFormatter * * @return \RcmErrorHandler\Format\FormatInterface | null */ public function getFormatter() { $format = $this->getFormat(); $formatConfig = $this->config->get('format'); if (!empty($formatConfig) && isset($formatConfig[$format])) { return new $formatConfig[$format]['class'](new Config($formatConfig[$format]['options'])); } return null; }
/** * getExtras * * @param GenericErrorInterface $error * * @return array */ protected function getExtras(GenericErrorInterface $error) { $formatter = new FormatBase(); $extras = ['file' => $error->getFile(), 'line' => $error->getLine(), 'message' => $error->getMessage(), 'exception' => null]; if ($this->options->get('includeStacktrace', false) == true) { $extras['trace'] = $formatter->getTraceString($error); } if ($error instanceof GenericExceptionInterface) { $extras['exception'] = $error->getException(); } return $extras; }
public function test() { $configArr = ['test' => 'testvalue']; $config = new Config($configArr); $test = $config->get('test'); $this->assertEquals('testvalue', $test); $nope = $config->get('nope'); $this->assertEquals(null, $nope); $not = $config->get('nope', 'not'); $this->assertEquals('not', $not); $all = $config->getAll(); $this->assertEquals($all, $configArr); }
/** * buildRelativePath * * @param $absoluteDir * * @return mixed */ public function cleanDirPath($absoluteDir) { $useFullPath = $this->config->get('useFullPath', false); if ($useFullPath) { return $absoluteDir; } $relativeDir = $absoluteDir; if (empty($this->appDir)) { $this->appDir = exec('pwd'); // or getcwd() } $dirLength = strlen($this->appDir); if (substr($absoluteDir, 0, $dirLength) == $this->appDir) { $relativeDir = substr_replace($absoluteDir, '', 0, $dirLength); } return $relativeDir; }