/**
  * Initializes instance members with supplied data.
  * @param mixed $data either error message (string) or criteria info (array)
  * @see create()
  * @see createError()
  * @see fromXml()
  */
 protected function __construct($data)
 {
     if (!is_array($data)) {
         $this->error = StringUtils::stripFunctionLinks($data);
     } else {
         $this->results = $data;
         $this->output = func_get_arg(1);
         $fulfillmentSum = 0;
         $passedCriteria = 0;
         $this->details = '';
         foreach ($data as $name => $criterion) {
             $fulfillmentSum += $criterion['fulfillment'];
             $passedCriteria += (int) $criterion['passed'];
             $this->details .= $name . ' ... ' . ($criterion['passed'] ? 'PASSED' : 'FAILED') . "\n";
             if ($criterion['details']) {
                 $this->details .= $criterion['details'] . "\n";
             }
         }
         $numCriteria = count($data);
         $this->details = "Passed {$passedCriteria} out of {$numCriteria} criteria.\n\n{$this->details}";
         $this->fulfillment = $numCriteria ? $fulfillmentSum / $numCriteria : 0;
     }
 }
Exemple #2
0
 /**
  * Creates message with custom formatting from supplied exception.
  * @param Exception $e
  * @return string error message with format: \<message\> (\<file\>:\<line\>)
  */
 protected static function getCustomMessage(Exception $e)
 {
     return StringUtils::stripFunctionLinks($e->getMessage()) . ' (' . basename($e->getFile()) . ':' . $e->getLine() . ')';
 }