~ballot/wordpress/openstack-objectstorage-breaking-insight

« back to all changes in this revision

Viewing changes to vendor/sebastian/comparator/src/ExceptionComparator.php

  • Committer: Jacek Nykis
  • Date: 2015-02-11 15:35:31 UTC
  • Revision ID: jacek.nykis@canonical.com-20150211153531-hmy6zi0ov2qfkl0b
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 * @package    Comparator
 
17
 * @author     Bernhard Schussek <bschussek@2bepublished.at>
 
18
 * @copyright  Sebastian Bergmann <sebastian@phpunit.de>
 
19
 * @license    http://www.opensource.org/licenses/BSD-3-Clause  The BSD 3-Clause License
 
20
 * @link       http://www.github.com/sebastianbergmann/comparator
 
21
 */
 
22
class ExceptionComparator extends ObjectComparator
 
23
{
 
24
    /**
 
25
     * Returns whether the comparator can compare two values.
 
26
     *
 
27
     * @param  mixed $expected The first value to compare
 
28
     * @param  mixed $actual The second value to compare
 
29
     * @return boolean
 
30
     */
 
31
    public function accepts($expected, $actual)
 
32
    {
 
33
        return $expected instanceof \Exception && $actual instanceof \Exception;
 
34
    }
 
35
 
 
36
    /**
 
37
     * Converts an object to an array containing all of its private, protected
 
38
     * and public properties.
 
39
     *
 
40
     * @param  object $object
 
41
     * @return array
 
42
     */
 
43
    protected function toArray($object)
 
44
    {
 
45
        $array = parent::toArray($object);
 
46
 
 
47
        unset(
 
48
            $array['file'],
 
49
            $array['line'],
 
50
            $array['trace'],
 
51
            $array['string'],
 
52
            $array['xdebug_message']
 
53
        );
 
54
 
 
55
        return $array;
 
56
    }
 
57
}