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 */ 15class PHPUnit_Util_InvalidArgumentHelper 16{ 17 /** 18 * @param int $argument 19 * @param string $type 20 * @param mixed $value 21 * 22 * @return PHPUnit_Framework_Exception 23 */ 24 public static function factory($argument, $type, $value = null) 25 { 26 $stack = debug_backtrace(false); 27 28 return new PHPUnit_Framework_Exception( 29 sprintf( 30 'Argument #%d%sof %s::%s() must be a %s', 31 $argument, 32 $value !== null ? ' (' . gettype($value) . '#' . $value . ')' : ' (No Value) ', 33 $stack[1]['class'], 34 $stack[1]['function'], 35 $type 36 ) 37 ); 38 } 39} 40