Version 1
[yaffs-website] / vendor / sebastian / comparator / src / ExceptionComparator.php
1 <?php
2 /*
3  * This file is part of the Comparator package.
4  *
5  * (c) Sebastian Bergmann <sebastian@phpunit.de>
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 SebastianBergmann\Comparator;
12
13 /**
14  * Compares Exception instances for equality.
15  */
16 class ExceptionComparator extends ObjectComparator
17 {
18     /**
19      * Returns whether the comparator can compare two values.
20      *
21      * @param  mixed $expected The first value to compare
22      * @param  mixed $actual   The second value to compare
23      * @return bool
24      */
25     public function accepts($expected, $actual)
26     {
27         return $expected instanceof \Exception && $actual instanceof \Exception;
28     }
29
30     /**
31      * Converts an object to an array containing all of its private, protected
32      * and public properties.
33      *
34      * @param  object $object
35      * @return array
36      */
37     protected function toArray($object)
38     {
39         $array = parent::toArray($object);
40
41         unset(
42             $array['file'],
43             $array['line'],
44             $array['trace'],
45             $array['string'],
46             $array['xdebug_message']
47         );
48
49         return $array;
50     }
51 }