Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
/**
3
 * Mockery
4
 *
5
 * LICENSE
6
 *
7
 * This source file is subject to the new BSD license that is bundled
8
 * with this package in the file LICENSE.txt.
9
 * It is also available through the world-wide-web at this URL:
10
 * http://github.com/padraic/mockery/blob/master/LICENSE
11
 * If you did not receive a copy of the license and are unable to
12
 * obtain it through the world-wide-web, please send an email
13
 * to padraic@php.net so we can send you a copy immediately.
14
 *
15
 * @category   Mockery
16
 * @package    Mockery
17
 * @copyright  Copyright (c) 2010 Pádraic Brady (http://blog.astrumfutura.com)
18
 * @license    http://github.com/padraic/mockery/blob/master/LICENSE New BSD License
19
 */
20
 
21
namespace Mockery;
22
 
23
use Closure;
24
use Mockery\Matcher\NoArgs;
25
use Mockery\Matcher\AnyArgs;
26
use Mockery\Matcher\AndAnyOtherArgs;
27
use Mockery\Matcher\ArgumentListMatcher;
28
use Mockery\Matcher\MultiArgumentClosure;
29
 
30
class Expectation implements ExpectationInterface
31
{
32
    /**
33
     * Mock object to which this expectation belongs
34
     *
35
     * @var \Mockery\LegacyMockInterface
36
     */
37
    protected $_mock = null;
38
 
39
    /**
40
     * Method name
41
     *
42
     * @var string
43
     */
44
    protected $_name = null;
45
 
46
    /**
47
     * Exception message
48
     *
49
     * @var string|null
50
     */
51
    protected $_because = null;
52
 
53
    /**
54
     * Arguments expected by this expectation
55
     *
56
     * @var array
57
     */
58
    protected $_expectedArgs = array();
59
 
60
    /**
61
     * Count validator store
62
     *
63
     * @var array
64
     */
65
    protected $_countValidators = array();
66
 
67
    /**
68
     * The count validator class to use
69
     *
70
     * @var string
71
     */
72
    protected $_countValidatorClass = 'Mockery\CountValidator\Exact';
73
 
74
    /**
75
     * Actual count of calls to this expectation
76
     *
77
     * @var int
78
     */
79
    protected $_actualCount = 0;
80
 
81
    /**
82
     * Value to return from this expectation
83
     *
84
     * @var mixed
85
     */
86
    protected $_returnValue = null;
87
 
88
    /**
89
     * Array of return values as a queue for multiple return sequence
90
     *
91
     * @var array
92
     */
93
    protected $_returnQueue = array();
94
 
95
    /**
96
     * Array of closures executed with given arguments to generate a result
97
     * to be returned
98
     *
99
     * @var array
100
     */
101
    protected $_closureQueue = array();
102
 
103
    /**
104
     * Array of values to be set when this expectation matches
105
     *
106
     * @var array
107
     */
108
    protected $_setQueue = array();
109
 
110
    /**
111
     * Integer representing the call order of this expectation
112
     *
113
     * @var int
114
     */
115
    protected $_orderNumber = null;
116
 
117
    /**
118
     * Integer representing the call order of this expectation on a global basis
119
     *
120
     * @var int
121
     */
122
    protected $_globalOrderNumber = null;
123
 
124
    /**
125
     * Flag indicating that an exception is expected to be throw (not returned)
126
     *
127
     * @var bool
128
     */
129
    protected $_throw = false;
130
 
131
    /**
132
     * Flag indicating whether the order of calling is determined locally or
133
     * globally
134
     *
135
     * @var bool
136
     */
137
    protected $_globally = false;
138
 
139
    /**
140
     * Flag indicating if the return value should be obtained from the original
141
     * class method instead of returning predefined values from the return queue
142
     *
143
     * @var bool
144
     */
145
    protected $_passthru = false;
146
 
147
    /**
148
     * Constructor
149
     *
150
     * @param \Mockery\LegacyMockInterface $mock
151
     * @param string $name
152
     */
153
    public function __construct(\Mockery\LegacyMockInterface $mock, $name)
154
    {
155
        $this->_mock = $mock;
156
        $this->_name = $name;
157
        $this->withAnyArgs();
158
    }
159
 
160
    /**
161
     * Return a string with the method name and arguments formatted
162
     *
163
     * @param string $name Name of the expected method
164
     * @param array $args List of arguments to the method
165
     * @return string
166
     */
167
    public function __toString()
168
    {
169
        return \Mockery::formatArgs($this->_name, $this->_expectedArgs);
170
    }
171
 
172
    /**
173
     * Verify the current call, i.e. that the given arguments match those
174
     * of this expectation
175
     *
176
     * @param array $args
177
     * @return mixed
178
     */
179
    public function verifyCall(array $args)
180
    {
181
        $this->validateOrder();
182
        $this->_actualCount++;
183
        if (true === $this->_passthru) {
184
            return $this->_mock->mockery_callSubjectMethod($this->_name, $args);
185
        }
186
 
187
        $return = $this->_getReturnValue($args);
188
        $this->throwAsNecessary($return);
189
        $this->_setValues();
190
 
191
        return $return;
192
    }
193
 
194
    /**
195
     * Throws an exception if the expectation has been configured to do so
196
     *
197
     * @throws \Throwable
198
     * @return void
199
     */
200
    private function throwAsNecessary($return)
201
    {
202
        if (!$this->_throw) {
203
            return;
204
        }
205
 
206
        if ($return instanceof \Throwable) {
207
            throw $return;
208
        }
209
 
210
        return;
211
    }
212
 
213
    /**
214
     * Sets public properties with queued values to the mock object
215
     *
216
     * @param array $args
217
     * @return mixed
218
     */
219
    protected function _setValues()
220
    {
221
        $mockClass = get_class($this->_mock);
222
        $container = $this->_mock->mockery_getContainer();
223
        /** @var Mock[] $mocks */
224
        $mocks = $container->getMocks();
225
        foreach ($this->_setQueue as $name => &$values) {
226
            if (count($values) > 0) {
227
                $value = array_shift($values);
228
                $this->_mock->{$name} = $value;
229
                foreach ($mocks as $mock) {
230
                    if (is_a($mock, $mockClass) && $mock->mockery_isInstance()) {
231
                        $mock->{$name} = $value;
232
                    }
233
                }
234
            }
235
        }
236
    }
237
 
238
    /**
239
     * Fetch the return value for the matching args
240
     *
241
     * @param array $args
242
     * @return mixed
243
     */
244
    protected function _getReturnValue(array $args)
245
    {
246
        if (count($this->_closureQueue) > 1) {
247
            return call_user_func_array(array_shift($this->_closureQueue), $args);
248
        } elseif (count($this->_closureQueue) > 0) {
249
            return call_user_func_array(current($this->_closureQueue), $args);
250
        } elseif (count($this->_returnQueue) > 1) {
251
            return array_shift($this->_returnQueue);
252
        } elseif (count($this->_returnQueue) > 0) {
253
            return current($this->_returnQueue);
254
        }
255
 
256
        return $this->_mock->mockery_returnValueForMethod($this->_name);
257
    }
258
 
259
    /**
260
     * Checks if this expectation is eligible for additional calls
261
     *
262
     * @return bool
263
     */
264
    public function isEligible()
265
    {
266
        foreach ($this->_countValidators as $validator) {
267
            if (!$validator->isEligible($this->_actualCount)) {
268
                return false;
269
            }
270
        }
271
        return true;
272
    }
273
 
274
    /**
275
     * Check if there is a constraint on call count
276
     *
277
     * @return bool
278
     */
279
    public function isCallCountConstrained()
280
    {
281
        return (count($this->_countValidators) > 0);
282
    }
283
 
284
    /**
285
     * Verify call order
286
     *
287
     * @return void
288
     */
289
    public function validateOrder()
290
    {
291
        if ($this->_orderNumber) {
292
            $this->_mock->mockery_validateOrder((string) $this, $this->_orderNumber, $this->_mock);
293
        }
294
        if ($this->_globalOrderNumber) {
295
            $this->_mock->mockery_getContainer()
296
                ->mockery_validateOrder((string) $this, $this->_globalOrderNumber, $this->_mock);
297
        }
298
    }
299
 
300
    /**
301
     * Verify this expectation
302
     *
303
     * @return void
304
     */
305
    public function verify()
306
    {
307
        foreach ($this->_countValidators as $validator) {
308
            $validator->validate($this->_actualCount);
309
        }
310
    }
311
 
312
    /**
313
     * Check if the registered expectation is an ArgumentListMatcher
314
     * @return bool
315
     */
316
    private function isArgumentListMatcher()
317
    {
318
        return (count($this->_expectedArgs) === 1 && ($this->_expectedArgs[0] instanceof ArgumentListMatcher));
319
    }
320
 
321
    private function isAndAnyOtherArgumentsMatcher($expectedArg)
322
    {
323
        return $expectedArg instanceof AndAnyOtherArgs;
324
    }
325
 
326
    /**
327
     * Check if passed arguments match an argument expectation
328
     *
329
     * @param array $args
330
     * @return bool
331
     */
332
    public function matchArgs(array $args)
333
    {
334
        if ($this->isArgumentListMatcher()) {
335
            return $this->_matchArg($this->_expectedArgs[0], $args);
336
        }
337
        $argCount = count($args);
338
        if ($argCount !== count((array) $this->_expectedArgs)) {
339
            $lastExpectedArgument = end($this->_expectedArgs);
340
            reset($this->_expectedArgs);
341
 
342
            if ($this->isAndAnyOtherArgumentsMatcher($lastExpectedArgument)) {
343
                $args = array_slice($args, 0, array_search($lastExpectedArgument, $this->_expectedArgs, true));
344
                return $this->_matchArgs($args);
345
            }
346
 
347
            return false;
348
        }
349
 
350
        return $this->_matchArgs($args);
351
    }
352
 
353
    /**
354
     * Check if the passed arguments match the expectations, one by one.
355
     *
356
     * @param array $args
357
     * @return bool
358
     */
359
    protected function _matchArgs($args)
360
    {
361
        $argCount = count($args);
362
        for ($i=0; $i<$argCount; $i++) {
363
            $param =& $args[$i];
364
            if (!$this->_matchArg($this->_expectedArgs[$i], $param)) {
365
                return false;
366
            }
367
        }
368
        return true;
369
    }
370
 
371
    /**
372
     * Check if passed argument matches an argument expectation
373
     *
374
     * @param mixed $expected
375
     * @param mixed $actual
376
     * @return bool
377
     */
378
    protected function _matchArg($expected, &$actual)
379
    {
380
        if ($expected === $actual) {
381
            return true;
382
        }
383
        if (!is_object($expected) && !is_object($actual) && $expected == $actual) {
384
            return true;
385
        }
386
        if (is_string($expected) && is_object($actual)) {
387
            $result = $actual instanceof $expected;
388
            if ($result) {
389
                return true;
390
            }
391
        }
392
        if (is_object($expected)) {
393
            $matcher = \Mockery::getConfiguration()->getDefaultMatcher(get_class($expected));
394
            if ($matcher !== null) {
395
                $expected = new $matcher($expected);
396
            }
397
        }
398
        if ($expected instanceof \Mockery\Matcher\MatcherAbstract) {
399
            return $expected->match($actual);
400
        }
401
        if ($expected instanceof \Hamcrest\Matcher || $expected instanceof \Hamcrest_Matcher) {
402
            return $expected->matches($actual);
403
        }
404
        return false;
405
    }
406
 
407
    /**
408
     * Expected argument setter for the expectation
409
     *
410
     * @param mixed ...$args
411
     *
412
     * @return self
413
     */
414
    public function with(...$args)
415
    {
416
        return $this->withArgs($args);
417
    }
418
 
419
    /**
420
     * Expected arguments for the expectation passed as an array
421
     *
422
     * @param array $arguments
423
     * @return self
424
     */
425
    private function withArgsInArray(array $arguments)
426
    {
427
        if (empty($arguments)) {
428
            return $this->withNoArgs();
429
        }
430
        $this->_expectedArgs = $arguments;
431
        return $this;
432
    }
433
 
434
    /**
435
     * Expected arguments have to be matched by the given closure.
436
     *
437
     * @param Closure $closure
438
     * @return self
439
     */
440
    private function withArgsMatchedByClosure(Closure $closure)
441
    {
442
        $this->_expectedArgs = [new MultiArgumentClosure($closure)];
443
        return $this;
444
    }
445
 
446
    /**
447
     * Expected arguments for the expectation passed as an array or a closure that matches each passed argument on
448
     * each function call.
449
     *
450
     * @param array|Closure $argsOrClosure
451
     * @return self
452
     */
453
    public function withArgs($argsOrClosure)
454
    {
455
        if (is_array($argsOrClosure)) {
456
            $this->withArgsInArray($argsOrClosure);
457
        } elseif ($argsOrClosure instanceof Closure) {
458
            $this->withArgsMatchedByClosure($argsOrClosure);
459
        } else {
460
            throw new \InvalidArgumentException(sprintf('Call to %s with an invalid argument (%s), only array and ' .
461
                'closure are allowed', __METHOD__, $argsOrClosure));
462
        }
463
        return $this;
464
    }
465
 
466
    /**
467
     * Set with() as no arguments expected
468
     *
469
     * @return self
470
     */
471
    public function withNoArgs()
472
    {
473
        $this->_expectedArgs = [new NoArgs()];
474
        return $this;
475
    }
476
 
477
    /**
478
     * Set expectation that any arguments are acceptable
479
     *
480
     * @return self
481
     */
482
    public function withAnyArgs()
483
    {
484
        $this->_expectedArgs = [new AnyArgs()];
485
        return $this;
486
    }
487
 
488
    /**
489
     * Expected arguments should partially match the real arguments
490
     *
491
     * @param mixed ...$expectedArgs
492
     * @return self
493
     */
494
    public function withSomeOfArgs(...$expectedArgs)
495
    {
496
        return $this->withArgs(function (...$args) use ($expectedArgs) {
497
            foreach ($expectedArgs as $expectedArg) {
498
                if (!in_array($expectedArg, $args, true)) {
499
                    return false;
500
                }
501
            }
502
            return true;
503
        });
504
    }
505
 
506
    /**
507
     * Set a return value, or sequential queue of return values
508
     *
509
     * @param mixed ...$args
510
     * @return self
511
     */
512
    public function andReturn(...$args)
513
    {
514
        $this->_returnQueue = $args;
515
        return $this;
516
    }
517
 
518
    /**
519
     * Set a return value, or sequential queue of return values
520
     *
521
     * @param mixed ...$args
522
     * @return self
523
     */
524
    public function andReturns(...$args)
525
    {
526
        return call_user_func_array([$this, 'andReturn'], $args);
527
    }
528
 
529
    /**
530
     * Return this mock, like a fluent interface
531
     *
532
     * @return self
533
     */
534
    public function andReturnSelf()
535
    {
536
        return $this->andReturn($this->_mock);
537
    }
538
 
539
    /**
540
     * Set a sequential queue of return values with an array
541
     *
542
     * @param array $values
543
     * @return self
544
     */
545
    public function andReturnValues(array $values)
546
    {
547
        call_user_func_array(array($this, 'andReturn'), $values);
548
        return $this;
549
    }
550
 
551
    /**
552
     * Set a closure or sequence of closures with which to generate return
553
     * values. The arguments passed to the expected method are passed to the
554
     * closures as parameters.
555
     *
556
     * @param callable ...$args
557
     * @return self
558
     */
559
    public function andReturnUsing(...$args)
560
    {
561
        $this->_closureQueue = $args;
562
        return $this;
563
    }
564
 
565
    /**
566
     * Sets up a closure to return the nth argument from the expected method call
567
     *
568
     * @param int $index
569
     * @return self
570
     */
571
    public function andReturnArg($index)
572
    {
573
        if (!is_int($index) || $index < 0) {
574
            throw new \InvalidArgumentException("Invalid argument index supplied. Index must be a non-negative integer.");
575
        }
576
        $closure = function (...$args) use ($index) {
577
            if (array_key_exists($index, $args)) {
578
                return $args[$index];
579
            }
580
            throw new \OutOfBoundsException("Cannot return an argument value. No argument exists for the index $index");
581
        };
582
 
583
        $this->_closureQueue = [$closure];
584
        return $this;
585
    }
586
 
587
    /**
588
     * Return a self-returning black hole object.
589
     *
590
     * @return self
591
     */
592
    public function andReturnUndefined()
593
    {
594
        $this->andReturn(new \Mockery\Undefined());
595
        return $this;
596
    }
597
 
598
    /**
599
     * Return null. This is merely a language construct for Mock describing.
600
     *
601
     * @return self
602
     */
603
    public function andReturnNull()
604
    {
605
        return $this->andReturn(null);
606
    }
607
 
608
    public function andReturnFalse()
609
    {
610
        return $this->andReturn(false);
611
    }
612
 
613
    public function andReturnTrue()
614
    {
615
        return $this->andReturn(true);
616
    }
617
 
618
    /**
619
     * Set Exception class and arguments to that class to be thrown
620
     *
621
     * @param string|\Exception $exception
622
     * @param string $message
623
     * @param int $code
624
     * @param \Exception $previous
625
     * @return self
626
     */
627
    public function andThrow($exception, $message = '', $code = 0, \Exception $previous = null)
628
    {
629
        $this->_throw = true;
630
        if (is_object($exception)) {
631
            $this->andReturn($exception);
632
        } else {
633
            $this->andReturn(new $exception($message, $code, $previous));
634
        }
635
        return $this;
636
    }
637
 
638
    public function andThrows($exception, $message = '', $code = 0, \Exception $previous = null)
639
    {
640
        return $this->andThrow($exception, $message, $code, $previous);
641
    }
642
 
643
    /**
644
     * Set Exception classes to be thrown
645
     *
646
     * @param array $exceptions
647
     * @return self
648
     */
649
    public function andThrowExceptions(array $exceptions)
650
    {
651
        $this->_throw = true;
652
        foreach ($exceptions as $exception) {
653
            if (!is_object($exception)) {
654
                throw new Exception('You must pass an array of exception objects to andThrowExceptions');
655
            }
656
        }
657
        return $this->andReturnValues($exceptions);
658
    }
659
 
660
    /**
661
     * Register values to be set to a public property each time this expectation occurs
662
     *
663
     * @param string $name
664
     * @param array ...$values
665
     * @return self
666
     */
667
    public function andSet($name, ...$values)
668
    {
669
        $this->_setQueue[$name] = $values;
670
        return $this;
671
    }
672
 
673
    /**
674
     * Sets up a closure that will yield each of the provided args
675
     *
676
     * @param mixed ...$args
677
     * @return self
678
     */
679
    public function andYield(...$args)
680
    {
681
        $this->_closureQueue = [
682
            static function () use ($args) {
683
                foreach ($args as $arg) {
684
                    yield $arg;
685
                }
686
            },
687
        ];
688
 
689
        return $this;
690
    }
691
 
692
    /**
693
     * Alias to andSet(). Allows the natural English construct
694
     * - set('foo', 'bar')->andReturn('bar')
695
     *
696
     * @param string $name
697
     * @param mixed $value
698
     * @return self
699
     */
700
    public function set($name, $value)
701
    {
702
        return call_user_func_array(array($this, 'andSet'), func_get_args());
703
    }
704
 
705
    /**
706
     * Indicates this expectation should occur zero or more times
707
     *
708
     * @return self
709
     */
710
    public function zeroOrMoreTimes()
711
    {
712
        $this->atLeast()->never();
713
    }
714
 
715
    /**
716
     * Indicates the number of times this expectation should occur
717
     *
718
     * @param int $limit
719
     * @throws \InvalidArgumentException
720
     * @return self
721
     */
722
    public function times($limit = null)
723
    {
724
        if (is_null($limit)) {
725
            return $this;
726
        }
727
        if (!is_int($limit)) {
728
            throw new \InvalidArgumentException('The passed Times limit should be an integer value');
729
        }
730
        $this->_countValidators[$this->_countValidatorClass] = new $this->_countValidatorClass($this, $limit);
731
 
732
        if ('Mockery\CountValidator\Exact' !== $this->_countValidatorClass) {
733
            $this->_countValidatorClass = 'Mockery\CountValidator\Exact';
734
            unset($this->_countValidators[$this->_countValidatorClass]);
735
        }
736
 
737
        return $this;
738
    }
739
 
740
    /**
741
     * Indicates that this expectation is never expected to be called
742
     *
743
     * @return self
744
     */
745
    public function never()
746
    {
747
        return $this->times(0);
748
    }
749
 
750
    /**
751
     * Indicates that this expectation is expected exactly once
752
     *
753
     * @return self
754
     */
755
    public function once()
756
    {
757
        return $this->times(1);
758
    }
759
 
760
    /**
761
     * Indicates that this expectation is expected exactly twice
762
     *
763
     * @return self
764
     */
765
    public function twice()
766
    {
767
        return $this->times(2);
768
    }
769
 
770
    /**
771
     * Sets next count validator to the AtLeast instance
772
     *
773
     * @return self
774
     */
775
    public function atLeast()
776
    {
777
        $this->_countValidatorClass = 'Mockery\CountValidator\AtLeast';
778
        return $this;
779
    }
780
 
781
    /**
782
     * Sets next count validator to the AtMost instance
783
     *
784
     * @return self
785
     */
786
    public function atMost()
787
    {
788
        $this->_countValidatorClass = 'Mockery\CountValidator\AtMost';
789
        return $this;
790
    }
791
 
792
    /**
793
     * Shorthand for setting minimum and maximum constraints on call counts
794
     *
795
     * @param int $minimum
796
     * @param int $maximum
797
     */
798
    public function between($minimum, $maximum)
799
    {
800
        return $this->atLeast()->times($minimum)->atMost()->times($maximum);
801
    }
802
 
803
 
804
    /**
805
     * Set the exception message
806
     *
807
     * @param string $message
808
     * @return $this
809
     */
810
    public function because($message)
811
    {
812
        $this->_because = $message;
813
        return $this;
814
    }
815
 
816
    /**
817
     * Indicates that this expectation must be called in a specific given order
818
     *
819
     * @param string $group Name of the ordered group
820
     * @return self
821
     */
822
    public function ordered($group = null)
823
    {
824
        if ($this->_globally) {
825
            $this->_globalOrderNumber = $this->_defineOrdered($group, $this->_mock->mockery_getContainer());
826
        } else {
827
            $this->_orderNumber = $this->_defineOrdered($group, $this->_mock);
828
        }
829
        $this->_globally = false;
830
        return $this;
831
    }
832
 
833
    /**
834
     * Indicates call order should apply globally
835
     *
836
     * @return self
837
     */
838
    public function globally()
839
    {
840
        $this->_globally = true;
841
        return $this;
842
    }
843
 
844
    /**
845
     * Setup the ordering tracking on the mock or mock container
846
     *
847
     * @param string $group
848
     * @param object $ordering
849
     * @return int
850
     */
851
    protected function _defineOrdered($group, $ordering)
852
    {
853
        $groups = $ordering->mockery_getGroups();
854
        if (is_null($group)) {
855
            $result = $ordering->mockery_allocateOrder();
856
        } elseif (isset($groups[$group])) {
857
            $result = $groups[$group];
858
        } else {
859
            $result = $ordering->mockery_allocateOrder();
860
            $ordering->mockery_setGroup($group, $result);
861
        }
862
        return $result;
863
    }
864
 
865
    /**
866
     * Return order number
867
     *
868
     * @return int
869
     */
870
    public function getOrderNumber()
871
    {
872
        return $this->_orderNumber;
873
    }
874
 
875
    /**
876
     * Mark this expectation as being a default
877
     *
878
     * @return self
879
     */
880
    public function byDefault()
881
    {
882
        $director = $this->_mock->mockery_getExpectationsFor($this->_name);
883
        if (!empty($director)) {
884
            $director->makeExpectationDefault($this);
885
        }
886
        return $this;
887
    }
888
 
889
    /**
890
     * Return the parent mock of the expectation
891
     *
892
     * @return \Mockery\LegacyMockInterface|\Mockery\MockInterface
893
     */
894
    public function getMock()
895
    {
896
        return $this->_mock;
897
    }
898
 
899
    /**
900
     * Flag this expectation as calling the original class method with the
901
     * any provided arguments instead of using a return value queue.
902
     *
903
     * @return self
904
     */
905
    public function passthru()
906
    {
907
        if ($this->_mock instanceof Mock) {
908
            throw new Exception(
909
                'Mock Objects not created from a loaded/existing class are '
910
                . 'incapable of passing method calls through to a parent class'
911
            );
912
        }
913
        $this->_passthru = true;
914
        return $this;
915
    }
916
 
917
    /**
918
     * Cloning logic
919
     *
920
     */
921
    public function __clone()
922
    {
923
        $newValidators = array();
924
        $countValidators = $this->_countValidators;
925
        foreach ($countValidators as $validator) {
926
            $newValidators[] = clone $validator;
927
        }
928
        $this->_countValidators = $newValidators;
929
    }
930
 
931
    public function getName()
932
    {
933
        return $this->_name;
934
    }
935
 
936
    public function getExceptionMessage()
937
    {
938
        return $this->_because;
939
    }
940
}