Pull merge.
[yaffs-website] / vendor / phpunit / phpunit-mock-objects / src / Framework / MockObject / Stub / ReturnSelf.php
1 <?php
2 /*
3  * This file is part of the PHPUnit_MockObject 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 /**
12  * Stubs a method by returning the current object.
13  *
14  * @since Class available since Release 1.1.0
15  */
16 class PHPUnit_Framework_MockObject_Stub_ReturnSelf implements PHPUnit_Framework_MockObject_Stub
17 {
18     public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation)
19     {
20         if (!$invocation instanceof PHPUnit_Framework_MockObject_Invocation_Object) {
21             throw new PHPUnit_Framework_Exception(
22                 'The current object can only be returned when mocking an ' .
23                 'object, not a static class.'
24             );
25         }
26
27         return $invocation->object;
28     }
29
30     public function toString()
31     {
32         return 'return the current object';
33     }
34 }