1: <?php
2:
3: /**
4: * Copyright 2015, Eduardo Trujillo
5: *
6: * For the full copyright and license information, please view the LICENSE
7: * file that was distributed with this source code.
8: *
9: * This file is part of the Nucleus package
10: */
11:
12: namespace Chromabits\Nucleus\Meditation\Exceptions;
13:
14: use Chromabits\Nucleus\Data\ArrayList;
15: use Chromabits\Nucleus\Meditation\TypeHound;
16:
17: /**
18: * Class MismatchedArgumentTypesException.
19: *
20: * @author Eduardo Trujillo <ed@chromabits.com>
21: * @package Chromabits\Nucleus\Meditation\Exceptions
22: */
23: class MismatchedArgumentTypesException extends InvalidArgumentException
24: {
25: /**
26: * Construct an instance of a MismatchedArgumentTypesException.
27: *
28: * @param string $functionName
29: * @param mixed $arguments
30: */
31: public function __construct($functionName, ...$arguments)
32: {
33: parent::__construct(
34: vsprintf(
35: 'Argument type mismatch: %s for function %s',
36: [
37: ArrayList::of($arguments)
38: ->map(function ($item) {
39: return TypeHound::fetch($item);
40: })
41: ->join(', '),
42: $functionName,
43: ]
44: )
45: );
46: }
47: }
48: