Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Testwork / Tester / Result / ResultInterpreter.php
1 <?php
2
3 /*
4  * This file is part of the Behat.
5  * (c) Konstantin Kudryashov <ever.zet@gmail.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 namespace Behat\Testwork\Tester\Result;
12
13 use Behat\Testwork\Tester\Result\Interpretation\ResultInterpretation;
14
15 /**
16  * Interprets provided test result (as 1 or 0) using registered interpretations.
17  *
18  * @author Konstantin Kudryashov <ever.zet@gmail.com>
19  */
20 final class ResultInterpreter
21 {
22     /**
23      * @var ResultInterpretation[]
24      */
25     private $interpretations = array();
26
27     /**
28      * Registers result interpretation.
29      *
30      * @param ResultInterpretation $interpretation
31      */
32     public function registerResultInterpretation(ResultInterpretation $interpretation)
33     {
34         $this->interpretations[] = $interpretation;
35     }
36
37     /**
38      * Interprets result as a UNIX return code (0 for success, 1 for failure).
39      *
40      * @param TestResult $result
41      *
42      * @return integer
43      */
44     public function interpretResult(TestResult $result)
45     {
46         foreach ($this->interpretations as $interpretation) {
47             if ($interpretation->isFailure($result)) {
48                 return 1;
49             }
50         }
51
52         return 0;
53     }
54 }