Example #1
0
 /**
  * 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;
 }
Example #3
0
 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);
 }
Example #4
0
 /**
  * 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;
 }