Version 1
[yaffs-website] / vendor / phpunit / phpunit / src / Util / InvalidArgumentHelper.php
1 <?php
2 /*
3  * This file is part of PHPUnit.
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  * Factory for PHPUnit_Framework_Exception objects that are used to describe
13  * invalid arguments passed to a function or method.
14  *
15  * @since Class available since Release 3.4.0
16  */
17 class PHPUnit_Util_InvalidArgumentHelper
18 {
19     /**
20      * @param int    $argument
21      * @param string $type
22      * @param mixed  $value
23      *
24      * @return PHPUnit_Framework_Exception
25      */
26     public static function factory($argument, $type, $value = null)
27     {
28         $stack = debug_backtrace(false);
29
30         return new PHPUnit_Framework_Exception(
31             sprintf(
32                 'Argument #%d%sof %s::%s() must be a %s',
33                 $argument,
34                 $value !== null ? ' (' . gettype($value) . '#' . $value . ')' : ' (No Value) ',
35                 $stack[1]['class'],
36                 $stack[1]['function'],
37                 $type
38             )
39         );
40     }
41 }