~tcuthbert/wordpress/openstack-objectstorage

« back to all changes in this revision

Viewing changes to vendor/phpunit/phpunit/src/Util/InvalidArgumentHelper.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 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
 * @package    PHPUnit
 
16
 * @subpackage Util
 
17
 * @author     Sebastian Bergmann <sebastian@phpunit.de>
 
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.phpunit.de/
 
21
 * @since      Class available since Release 3.4.0
 
22
 */
 
23
class PHPUnit_Util_InvalidArgumentHelper
 
24
{
 
25
    /**
 
26
     * @param  integer                     $argument
 
27
     * @param  string                      $type
 
28
     * @param  mixed                       $value
 
29
     * @return PHPUnit_Framework_Exception
 
30
     */
 
31
    public static function factory($argument, $type, $value = null)
 
32
    {
 
33
        $stack = debug_backtrace(false);
 
34
 
 
35
        return new PHPUnit_Framework_Exception(
 
36
            sprintf(
 
37
                'Argument #%d%sof %s::%s() must be a %s',
 
38
                $argument,
 
39
                $value !== null ? ' (' . gettype($value) . '#' . $value . ')' : ' (No Value) ',
 
40
                $stack[1]['class'],
 
41
                $stack[1]['function'],
 
42
                $type
 
43
            )
 
44
        );
 
45
    }
 
46
}