1: <?php
2: namespace Peridot\Leo\Interfaces\Assert;
3:
4: use Countable;
5:
6: /**
7: * CollectionAssertTrait contains assertions that primarily
8: * deal with collections and countable values.
9: *
10: * @package Peridot\Leo\Interfaces\Assert
11: */
12: trait CollectionAssertTrait
13: {
14: /**
15: * Perform a length assertion.
16: *
17: * @param string|array|Countable $countable
18: * @param $length
19: * @param string $message
20: */
21: public function lengthOf($countable, $length, $message = "")
22: {
23: $this->assertion->setActual($countable);
24: return $this->assertion->to->have->length($length, $message);
25: }
26:
27: /**
28: * Perform an inclusion assertion.
29: *
30: * @param array|string $haystack
31: * @param mixed $needle
32: * @param string $message
33: */
34: public function isIncluded($haystack, $needle, $message = "")
35: {
36: $this->assertion->setActual($haystack);
37: return $this->assertion->to->include($needle, $message);
38: }
39:
40: /**
41: * Perform a negated inclusion assertion.
42: *
43: * @param array|string $haystack
44: * @param mixed $needle
45: * @param string $message
46: */
47: public function notInclude($haystack, $needle, $message = "")
48: {
49: $this->assertion->setActual($haystack);
50: return $this->assertion->to->not->include($needle, $message);
51: }
52: }
53: