Click here to Skip to main content
Licence CPOL
First Posted 5 Jan 2012
Views 1,134
Bookmarked 3 times

LINQ for PHP

By | 5 Jan 2012 | Technical Blog
The driving forces behind LINQ for C# are extension methods. Without extension methods, LINQ becomes a cumbersome, syntax-heavy burden. It's this burden that I've translated to PHP.Below, you'll find a few LINQ-like methods for PHP. Each of the methods takes two arguments: a collection and a predica
A Technical Blog article. View original blog here.[^]

The driving forces behind LINQ for C# are extension methods. Without extension methods, LINQ becomes a cumbersome, syntax-heavy burden. It's this burden that I've translated to PHP.

Below, you'll find a few LINQ-like methods for PHP. Each of the methods takes two arguments: a collection and a predicate. The method simply iterates through the collection, tests the predicate against each item, and returns different results depending on the purpose of the call.

I've mimicked the following LINQ methods from C#:

  • Count
  • Where
  • Select
  • SelectMany
  • First
  • FirstOrDefault
  • Last
  • LastOrDefault

It's good to note that, not only is this manner of incorporating predicates compatible with PHP 5.2, it also doesn't rely on string parsing to create a lamda expression. The predicate is created with good-ol' create_function.

If you're looking for a full-fledged LINQ solution for PHP, check out PHPLinq.

As an added bonus, there's a simple yet effective test framework included in the example below. I'll try to write more about it some other time, but, for now, you should see the following result if you run the script in a browser:

Starting tests...
15 tests found.
Performing testAssertFailed...
Performing testAssertAreEqual...
Performing testAssertAreEqual2...
Performing testAssertAreNotEqual...
Performing testAssertAreNotEqual2...
Performing testAssertIsTrue...
Performing testAssertIsFalse...
Performing testCmGnWhere...
Performing testCmGnCount...
Performing testCmGnSelect...
Performing testCmGnSelectMany...
Performing testCmGnFirst...
Performing testCmGnFirstOrNull...
Performing testCmGnLast...
Performing testCmGnLastOrNull...
15 of 15 tests passed.

Stay tuned for the upcoming phpChimpanzee framework which contains more ugly solutions to everyday coding problems.

<span style="color: rgb(0, 0, 0); font-weight: bold; "><?php</span>
 
	<span style="color: rgb(0, 0, 0); font-weight: bold; ">class</span> cmGn <span style="color: rgb(0, 153, 0); ">{</span>
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">public</span> static <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> <a href="http://www.php.net/count"><span style="color: rgb(153, 0, 0); ">count</span></a><span style="color: rgb(0, 153, 0); ">(</span><a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a> <span style="color: rgb(0, 0, 136); ">$array</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 136); ">$predicate</span> <span style="color: rgb(51, 153, 51); ">=</span> <span style="color: rgb(0, 153, 0); font-weight: bold; ">null</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			<span style="color: rgb(177, 177, 0); ">if</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$predicate</span> <span style="color: rgb(51, 153, 51); ">===</span> <span style="color: rgb(0, 153, 0); font-weight: bold; ">null</span><span style="color: rgb(0, 153, 0); ">)</span>
				<span style="color: rgb(177, 177, 0); ">return</span> <a href="http://www.php.net/count"><span style="color: rgb(153, 0, 0); ">count</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$array</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(177, 177, 0); ">if</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(51, 153, 51); ">!</span><a href="http://www.php.net/is_callable"><span style="color: rgb(153, 0, 0); ">is_callable</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$predicate</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span>
				<span style="color: rgb(177, 177, 0); ">throw</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">new</span> cmGnException<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'Provided predicate is not a callable function.'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(0, 0, 136); ">$count</span> <span style="color: rgb(51, 153, 51); ">=</span> <span style="color: rgb(204, 102, 204); ">0</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(177, 177, 0); ">foreach</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$array</span> <span style="color: rgb(177, 177, 0); ">as</span> <span style="color: rgb(0, 0, 136); ">$item</span><span style="color: rgb(0, 153, 0); ">)</span>
				<span style="color: rgb(177, 177, 0); ">if</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$predicate</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$item</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(51, 153, 51); ">===</span> <span style="color: rgb(0, 153, 0); font-weight: bold; ">true</span><span style="color: rgb(0, 153, 0); ">)</span>
					<span style="color: rgb(0, 0, 136); ">$count</span><span style="color: rgb(51, 153, 51); ">++;</span>
			<span style="color: rgb(177, 177, 0); ">return</span> <span style="color: rgb(0, 0, 136); ">$count</span><span style="color: rgb(51, 153, 51); ">;</span>
		<span style="color: rgb(0, 153, 0); ">}</span>	
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">public</span> static <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> where<span style="color: rgb(0, 153, 0); ">(</span><a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a> <span style="color: rgb(0, 0, 136); ">$array</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 136); ">$predicate</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			<span style="color: rgb(177, 177, 0); ">if</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(51, 153, 51); ">!</span><a href="http://www.php.net/is_callable"><span style="color: rgb(153, 0, 0); ">is_callable</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$predicate</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span>
				<span style="color: rgb(177, 177, 0); ">throw</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">new</span> cmGnException<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'Provided predicate is not a callable function.'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(0, 0, 136); ">$newAr</span> <span style="color: rgb(51, 153, 51); ">=</span> <a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(177, 177, 0); ">foreach</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$array</span> <span style="color: rgb(177, 177, 0); ">as</span> <span style="color: rgb(0, 0, 136); ">$item</span><span style="color: rgb(0, 153, 0); ">)</span>
				<span style="color: rgb(177, 177, 0); ">if</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$predicate</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$item</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(51, 153, 51); ">===</span> <span style="color: rgb(0, 153, 0); font-weight: bold; ">true</span><span style="color: rgb(0, 153, 0); ">)</span>
					<span style="color: rgb(0, 0, 136); ">$newAr</span><span style="color: rgb(0, 153, 0); ">[</span><span style="color: rgb(0, 153, 0); ">]</span> <span style="color: rgb(51, 153, 51); ">=</span> <span style="color: rgb(0, 0, 136); ">$item</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(177, 177, 0); ">return</span> <span style="color: rgb(0, 0, 136); ">$newAr</span><span style="color: rgb(51, 153, 51); ">;</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">public</span> static <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> select<span style="color: rgb(0, 153, 0); ">(</span><a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a> <span style="color: rgb(0, 0, 136); ">$array</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 136); ">$predicate</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			<span style="color: rgb(177, 177, 0); ">if</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(51, 153, 51); ">!</span><a href="http://www.php.net/is_callable"><span style="color: rgb(153, 0, 0); ">is_callable</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$predicate</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span>
				<span style="color: rgb(177, 177, 0); ">throw</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">new</span> cmGnException<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'Provided predicate is not a callable function.'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>		
			<span style="color: rgb(0, 0, 136); ">$newAr</span> <span style="color: rgb(51, 153, 51); ">=</span> <a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(177, 177, 0); ">foreach</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$array</span> <span style="color: rgb(177, 177, 0); ">as</span> <span style="color: rgb(0, 0, 136); ">$item</span><span style="color: rgb(0, 153, 0); ">)</span>
				<span style="color: rgb(0, 0, 136); ">$newAr</span><span style="color: rgb(0, 153, 0); ">[</span><span style="color: rgb(0, 153, 0); ">]</span> <span style="color: rgb(51, 153, 51); ">=</span> <span style="color: rgb(0, 0, 136); ">$predicate</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$item</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(177, 177, 0); ">return</span> <span style="color: rgb(0, 0, 136); ">$newAr</span><span style="color: rgb(51, 153, 51); ">;</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">public</span> static <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> selectMany<span style="color: rgb(0, 153, 0); ">(</span><a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a> <span style="color: rgb(0, 0, 136); ">$array</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 136); ">$predicate</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			<span style="color: rgb(177, 177, 0); ">if</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(51, 153, 51); ">!</span><a href="http://www.php.net/is_callable"><span style="color: rgb(153, 0, 0); ">is_callable</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$predicate</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span>
				<span style="color: rgb(177, 177, 0); ">throw</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">new</span> cmGnException<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'Provided predicate is not a callable function.'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>		
			<span style="color: rgb(0, 0, 136); ">$newAr</span> <span style="color: rgb(51, 153, 51); ">=</span> <a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(177, 177, 0); ">foreach</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$array</span> <span style="color: rgb(177, 177, 0); ">as</span> <span style="color: rgb(0, 0, 136); ">$item</span><span style="color: rgb(0, 153, 0); ">)</span>
				<span style="color: rgb(177, 177, 0); ">foreach</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$predicate</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$item</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(177, 177, 0); ">as</span> <span style="color: rgb(0, 0, 136); ">$newItem</span><span style="color: rgb(0, 153, 0); ">)</span>
					<span style="color: rgb(0, 0, 136); ">$newAr</span><span style="color: rgb(0, 153, 0); ">[</span><span style="color: rgb(0, 153, 0); ">]</span> <span style="color: rgb(51, 153, 51); ">=</span> <span style="color: rgb(0, 0, 136); ">$newItem</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(177, 177, 0); ">return</span> <span style="color: rgb(0, 0, 136); ">$newAr</span><span style="color: rgb(51, 153, 51); ">;</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">public</span> static <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> first<span style="color: rgb(0, 153, 0); ">(</span><a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a> <span style="color: rgb(0, 0, 136); ">$array</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 136); ">$predicate</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			<span style="color: rgb(177, 177, 0); ">if</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(51, 153, 51); ">!</span><a href="http://www.php.net/is_callable"><span style="color: rgb(153, 0, 0); ">is_callable</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$predicate</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span>
				<span style="color: rgb(177, 177, 0); ">throw</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">new</span> cmGnException<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'Provided predicate is not a callable function.'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>		
			<span style="color: rgb(177, 177, 0); ">foreach</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$array</span> <span style="color: rgb(177, 177, 0); ">as</span> <span style="color: rgb(0, 0, 136); ">$item</span><span style="color: rgb(0, 153, 0); ">)</span>
				<span style="color: rgb(177, 177, 0); ">if</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$predicate</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$item</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(51, 153, 51); ">===</span> <span style="color: rgb(0, 153, 0); font-weight: bold; ">true</span><span style="color: rgb(0, 153, 0); ">)</span>
					<span style="color: rgb(177, 177, 0); ">return</span> <span style="color: rgb(0, 0, 136); ">$item</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(177, 177, 0); ">throw</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">new</span> cmGnException<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'No items were found in the array parameter to return as the first item in a cmGn predicate query.'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">public</span> static <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> firstOrNull<span style="color: rgb(0, 153, 0); ">(</span><a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a> <span style="color: rgb(0, 0, 136); ">$array</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 136); ">$predicate</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			<span style="color: rgb(177, 177, 0); ">if</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(51, 153, 51); ">!</span><a href="http://www.php.net/is_callable"><span style="color: rgb(153, 0, 0); ">is_callable</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$predicate</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span>
				<span style="color: rgb(177, 177, 0); ">throw</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">new</span> cmGnException<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'Provided predicate is not a callable function.'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>		
			<span style="color: rgb(177, 177, 0); ">foreach</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$array</span> <span style="color: rgb(177, 177, 0); ">as</span> <span style="color: rgb(0, 0, 136); ">$item</span><span style="color: rgb(0, 153, 0); ">)</span>
				<span style="color: rgb(177, 177, 0); ">if</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$predicate</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$item</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(51, 153, 51); ">===</span> <span style="color: rgb(0, 153, 0); font-weight: bold; ">true</span><span style="color: rgb(0, 153, 0); ">)</span>
					<span style="color: rgb(177, 177, 0); ">return</span> <span style="color: rgb(0, 0, 136); ">$item</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(177, 177, 0); ">return</span> <span style="color: rgb(0, 153, 0); font-weight: bold; ">null</span><span style="color: rgb(51, 153, 51); ">;</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">public</span> static <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> last<span style="color: rgb(0, 153, 0); ">(</span><a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a> <span style="color: rgb(0, 0, 136); ">$array</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 136); ">$predicate</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			<span style="color: rgb(177, 177, 0); ">return</span> cmGn<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">first</span><span style="color: rgb(0, 153, 0); ">(</span><a href="http://www.php.net/array_reverse"><span style="color: rgb(153, 0, 0); ">array_reverse</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$array</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 136); ">$predicate</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">public</span> static <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> lastOrNull<span style="color: rgb(0, 153, 0); ">(</span><a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a> <span style="color: rgb(0, 0, 136); ">$array</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 136); ">$predicate</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			<span style="color: rgb(177, 177, 0); ">return</span> cmGn<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">firstOrNull</span><span style="color: rgb(0, 153, 0); ">(</span><a href="http://www.php.net/array_reverse"><span style="color: rgb(153, 0, 0); ">array_reverse</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$array</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 136); ">$predicate</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
	<span style="color: rgb(0, 153, 0); ">}</span>
 
	<span style="color: rgb(0, 0, 0); font-weight: bold; ">class</span> cmTest <span style="color: rgb(0, 153, 0); ">{</span>	
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">private</span> <span style="color: rgb(0, 0, 136); ">$testCount</span> <span style="color: rgb(51, 153, 51); ">=</span> <span style="color: rgb(204, 102, 204); ">0</span><span style="color: rgb(51, 153, 51); ">;</span>
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">private</span> <span style="color: rgb(0, 0, 136); ">$passCount</span> <span style="color: rgb(51, 153, 51); ">=</span> <span style="color: rgb(204, 102, 204); ">0</span><span style="color: rgb(51, 153, 51); ">;</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">protected</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> alert<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$message</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			<span style="color: rgb(177, 177, 0); ">echo</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'<p style="margin:0;padding:0">'</span> <span style="color: rgb(51, 153, 51); ">.</span> <span style="color: rgb(0, 0, 136); ">$message</span> <span style="color: rgb(51, 153, 51); ">.</span> <span style="color: rgb(0, 0, 255); ">'</p>'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">protected</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> testAssertFailed<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			try <span style="color: rgb(0, 153, 0); ">{</span>
				cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">failed</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
				<span style="color: rgb(0, 0, 136); ">$this</span><span style="color: rgb(51, 153, 51); ">-></span><span style="color: rgb(0, 64, 0); ">alert</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'Assert failed failed.'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(0, 153, 0); ">}</span>
			catch <span style="color: rgb(0, 153, 0); ">(</span>Exception <span style="color: rgb(0, 0, 136); ">$e</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
				<span style="color: rgb(102, 102, 102); font-style: italic; ">// The test passed if we got here.</span>
			<span style="color: rgb(0, 153, 0); ">}</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">protected</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> testAssertAreEqual<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			try <span style="color: rgb(0, 153, 0); ">{</span>
				cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">areEqual</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">1</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">1</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(0, 153, 0); ">}</span>
			catch <span style="color: rgb(0, 153, 0); ">(</span>Exception <span style="color: rgb(0, 0, 136); ">$e</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
				cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">failed</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(0, 153, 0); ">}</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">protected</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> testAssertAreEqual2<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			try <span style="color: rgb(0, 153, 0); ">{</span>
				cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">areEqual</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">1</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">2</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
				cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">failed</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(0, 153, 0); ">}</span>
			catch <span style="color: rgb(0, 153, 0); ">(</span>Exception <span style="color: rgb(0, 0, 136); ">$e</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
				<span style="color: rgb(102, 102, 102); font-style: italic; ">// The test passed if we got here.</span>
			<span style="color: rgb(0, 153, 0); ">}</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">protected</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> testAssertAreNotEqual<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			try <span style="color: rgb(0, 153, 0); ">{</span>
				cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">areNotEqual</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">1</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">2</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(0, 153, 0); ">}</span>
			catch <span style="color: rgb(0, 153, 0); ">(</span>Exception <span style="color: rgb(0, 0, 136); ">$e</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
				cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">failed</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(0, 153, 0); ">}</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">protected</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> testAssertAreNotEqual2<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			try <span style="color: rgb(0, 153, 0); ">{</span>
				cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">areNotEqual</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">1</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">1</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
				cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">failed</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(0, 153, 0); ">}</span>
			catch <span style="color: rgb(0, 153, 0); ">(</span>Exception <span style="color: rgb(0, 0, 136); ">$e</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
				<span style="color: rgb(102, 102, 102); font-style: italic; ">// The test passed if we got here.</span>
			<span style="color: rgb(0, 153, 0); ">}</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">protected</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> testAssertIsTrue<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			try <span style="color: rgb(0, 153, 0); ">{</span>
				cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">isTrue</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); font-weight: bold; ">true</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(0, 153, 0); ">}</span>
			catch <span style="color: rgb(0, 153, 0); ">(</span>Exception <span style="color: rgb(0, 0, 136); ">$e</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
				cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">failed</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(0, 153, 0); ">}</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">protected</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> testAssertIsFalse<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			try <span style="color: rgb(0, 153, 0); ">{</span>
				cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">isFalse</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); font-weight: bold; ">false</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(0, 153, 0); ">}</span>
			catch <span style="color: rgb(0, 153, 0); ">(</span>Exception <span style="color: rgb(0, 0, 136); ">$e</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
				cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">failed</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(0, 153, 0); ">}</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">protected</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> testCmGnWhere<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			<span style="color: rgb(0, 0, 136); ">$array</span> <span style="color: rgb(51, 153, 51); ">=</span> <a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">0</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">0</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">1</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">1</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">2</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">2</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">3</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">3</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">areEqual</span><span style="color: rgb(0, 153, 0); ">(</span>
				<span style="color: rgb(204, 102, 204); ">4</span><span style="color: rgb(51, 153, 51); ">,</span>
				<a href="http://www.php.net/count"><span style="color: rgb(153, 0, 0); ">count</span></a><span style="color: rgb(0, 153, 0); ">(</span>cmGn<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">where</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$array</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/create_function"><span style="color: rgb(153, 0, 0); ">create_function</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'$v'</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 255); ">'return $v < 2;'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span>
			<span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(177, 177, 0); ">foreach</span> <span style="color: rgb(0, 153, 0); ">(</span>cmGn<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">where</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$array</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/create_function"><span style="color: rgb(153, 0, 0); ">create_function</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'$v'</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 255); ">'return $v == 3;'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(177, 177, 0); ">as</span> <span style="color: rgb(0, 0, 136); ">$item</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
				cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">areEqual</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">3</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 136); ">$item</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(0, 153, 0); ">}</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">protected</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> testCmGnCount<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			<span style="color: rgb(0, 0, 136); ">$array</span> <span style="color: rgb(51, 153, 51); ">=</span> <a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">0</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">0</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">1</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">1</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">2</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">2</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">3</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">3</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">areEqual</span><span style="color: rgb(0, 153, 0); ">(</span>
				<span style="color: rgb(204, 102, 204); ">4</span><span style="color: rgb(51, 153, 51); ">,</span>
				cmGn<span style="color: rgb(51, 153, 51); ">::</span><a href="http://www.php.net/count"><span style="color: rgb(153, 0, 0); ">count</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$array</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/create_function"><span style="color: rgb(153, 0, 0); ">create_function</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'$v'</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 255); ">'return $v < 2;'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span>
			<span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">areEqual</span><span style="color: rgb(0, 153, 0); ">(</span>
				<span style="color: rgb(204, 102, 204); ">2</span><span style="color: rgb(51, 153, 51); ">,</span>
				cmGn<span style="color: rgb(51, 153, 51); ">::</span><a href="http://www.php.net/count"><span style="color: rgb(153, 0, 0); ">count</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$array</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/create_function"><span style="color: rgb(153, 0, 0); ">create_function</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'$v'</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 255); ">'return $v == 3;'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span>
			<span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">protected</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> testCmGnSelect<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			<span style="color: rgb(0, 0, 136); ">$array</span> <span style="color: rgb(51, 153, 51); ">=</span> <a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">0</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">0</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">1</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">1</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">2</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">2</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">3</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">3</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(0, 0, 136); ">$newAr</span> <span style="color: rgb(51, 153, 51); ">=</span> cmGn<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">select</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$array</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/create_function"><span style="color: rgb(153, 0, 0); ">create_function</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'$v'</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 255); ">'return $v - 1;'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(177, 177, 0); ">foreach</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$array</span> <span style="color: rgb(177, 177, 0); ">as</span> <span style="color: rgb(0, 0, 136); ">$item</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
				cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">isTrue</span><span style="color: rgb(0, 153, 0); ">(</span><a href="http://www.php.net/in_array"><span style="color: rgb(153, 0, 0); ">in_array</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$item</span> <span style="color: rgb(51, 153, 51); ">-</span> <span style="color: rgb(204, 102, 204); ">1</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 136); ">$newAr</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 153, 0); font-weight: bold; ">true</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(0, 153, 0); ">}</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">protected</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> testCmGnSelectMany<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			<span style="color: rgb(0, 0, 136); ">$array</span> <span style="color: rgb(51, 153, 51); ">=</span> <a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a><span style="color: rgb(0, 153, 0); ">(</span><a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">0</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">1</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">2</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">3</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">0</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">1</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">2</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">3</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">0</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">1</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">2</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">3</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(0, 0, 136); ">$newAr</span> <span style="color: rgb(51, 153, 51); ">=</span> cmGn<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">selectMany</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$array</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/create_function"><span style="color: rgb(153, 0, 0); ">create_function</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'$a'</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 255); ">'return $a;'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">areEqual</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">3</span><span style="color: rgb(51, 153, 51); ">,</span> cmGn<span style="color: rgb(51, 153, 51); ">::</span><a href="http://www.php.net/count"><span style="color: rgb(153, 0, 0); ">count</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$newAr</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/create_function"><span style="color: rgb(153, 0, 0); ">create_function</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'$v'</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 255); ">'return $v === 3;'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">areEqual</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">3</span><span style="color: rgb(51, 153, 51); ">,</span> cmGn<span style="color: rgb(51, 153, 51); ">::</span><a href="http://www.php.net/count"><span style="color: rgb(153, 0, 0); ">count</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$newAr</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/create_function"><span style="color: rgb(153, 0, 0); ">create_function</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'$v'</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 255); ">'return $v === 1;'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">areEqual</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">12</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/count"><span style="color: rgb(153, 0, 0); ">count</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$newAr</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">protected</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> testCmGnFirst<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			<span style="color: rgb(0, 0, 136); ">$array</span> <span style="color: rgb(51, 153, 51); ">=</span> <a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a><span style="color: rgb(0, 153, 0); ">(</span><a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">0</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">0</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">1</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">0</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">1</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">2</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(0, 0, 136); ">$first</span> <span style="color: rgb(51, 153, 51); ">=</span> cmGn<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">first</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$array</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/create_function"><span style="color: rgb(153, 0, 0); ">create_function</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'$a'</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 255); ">'return count($a) == 3;'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">areEqual</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">3</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/count"><span style="color: rgb(153, 0, 0); ">count</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$first</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">isTrue</span><span style="color: rgb(0, 153, 0); ">(</span><a href="http://www.php.net/in_array"><span style="color: rgb(153, 0, 0); ">in_array</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">2</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 136); ">$first</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			try <span style="color: rgb(0, 153, 0); ">{</span>
				<span style="color: rgb(0, 0, 136); ">$first</span> <span style="color: rgb(51, 153, 51); ">=</span> cmGn<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">first</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$array</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/create_function"><span style="color: rgb(153, 0, 0); ">create_function</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'$a'</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 255); ">'return count($a) == 4;'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
				cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">failed</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(0, 153, 0); ">}</span>
			catch <span style="color: rgb(0, 153, 0); ">(</span>cmGnException <span style="color: rgb(0, 0, 136); ">$e</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
				<span style="color: rgb(102, 102, 102); font-style: italic; ">// The test passed if we got here.</span>
			<span style="color: rgb(0, 153, 0); ">}</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">protected</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> testCmGnFirstOrNull<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			<span style="color: rgb(0, 0, 136); ">$array</span> <span style="color: rgb(51, 153, 51); ">=</span> <a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a><span style="color: rgb(0, 153, 0); ">(</span><a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">0</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">0</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">1</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">0</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">1</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">2</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(0, 0, 136); ">$first</span> <span style="color: rgb(51, 153, 51); ">=</span> cmGn<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">firstOrNull</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$array</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/create_function"><span style="color: rgb(153, 0, 0); ">create_function</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'$a'</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 255); ">'return count($a) == 3;'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">areEqual</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">3</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/count"><span style="color: rgb(153, 0, 0); ">count</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$first</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">isTrue</span><span style="color: rgb(0, 153, 0); ">(</span><a href="http://www.php.net/in_array"><span style="color: rgb(153, 0, 0); ">in_array</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">2</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 136); ">$first</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(0, 0, 136); ">$first</span> <span style="color: rgb(51, 153, 51); ">=</span> cmGn<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">firstOrNull</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$array</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/create_function"><span style="color: rgb(153, 0, 0); ">create_function</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'$a'</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 255); ">'return count($a) == 4;'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">areEqual</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); font-weight: bold; ">null</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 136); ">$first</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">protected</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> testCmGnLast<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			<span style="color: rgb(0, 0, 136); ">$array</span> <span style="color: rgb(51, 153, 51); ">=</span> <a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a><span style="color: rgb(0, 153, 0); ">(</span><a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">0</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">1</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">2</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">3</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">3</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">4</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(0, 0, 136); ">$last</span> <span style="color: rgb(51, 153, 51); ">=</span> cmGn<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">last</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$array</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/create_function"><span style="color: rgb(153, 0, 0); ">create_function</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'$a'</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 255); ">'return in_array(3, $a);'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">isTrue</span><span style="color: rgb(0, 153, 0); ">(</span><a href="http://www.php.net/in_array"><span style="color: rgb(153, 0, 0); ">in_array</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">4</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 136); ">$last</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			try <span style="color: rgb(0, 153, 0); ">{</span>
				<span style="color: rgb(0, 0, 136); ">$last</span> <span style="color: rgb(51, 153, 51); ">=</span> cmGn<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">last</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$array</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/create_function"><span style="color: rgb(153, 0, 0); ">create_function</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'$a'</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 255); ">'return in_array(5, $a);'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
				cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">failed</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(0, 153, 0); ">}</span>
			catch <span style="color: rgb(0, 153, 0); ">(</span>cmGnException <span style="color: rgb(0, 0, 136); ">$e</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
				<span style="color: rgb(102, 102, 102); font-style: italic; ">// The test passed if we got here.</span>
			<span style="color: rgb(0, 153, 0); ">}</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">protected</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> testCmGnLastOrNull<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			<span style="color: rgb(0, 0, 136); ">$array</span> <span style="color: rgb(51, 153, 51); ">=</span> <a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a><span style="color: rgb(0, 153, 0); ">(</span><a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">0</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">1</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">2</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">3</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">3</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(204, 102, 204); ">4</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(0, 0, 136); ">$last</span> <span style="color: rgb(51, 153, 51); ">=</span> cmGn<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">lastOrNull</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$array</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/create_function"><span style="color: rgb(153, 0, 0); ">create_function</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'$a'</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 255); ">'return in_array(3, $a);'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">isTrue</span><span style="color: rgb(0, 153, 0); ">(</span><a href="http://www.php.net/in_array"><span style="color: rgb(153, 0, 0); ">in_array</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(204, 102, 204); ">4</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 136); ">$last</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(0, 0, 136); ">$last</span> <span style="color: rgb(51, 153, 51); ">=</span> cmGn<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">lastOrNull</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$array</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/create_function"><span style="color: rgb(153, 0, 0); ">create_function</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'$a'</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 255); ">'return in_array(5, $a);'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			cmAssert<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">areEqual</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); font-weight: bold; ">null</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 136); ">$last</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">public</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> test<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			<span style="color: rgb(0, 0, 136); ">$this</span><span style="color: rgb(51, 153, 51); ">-></span><span style="color: rgb(0, 64, 0); ">alert</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'Starting tests...'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(0, 0, 136); ">$methd</span> <span style="color: rgb(51, 153, 51); ">=</span> <a href="http://www.php.net/get_class_methods"><span style="color: rgb(153, 0, 0); ">get_class_methods</span></a><span style="color: rgb(0, 153, 0); ">(</span><a href="http://www.php.net/get_class"><span style="color: rgb(153, 0, 0); ">get_class</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$this</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(0, 0, 136); ">$methd</span> <span style="color: rgb(51, 153, 51); ">=</span> <span style="color: rgb(0, 0, 136); ">$methd</span> ? <span style="color: rgb(0, 0, 136); ">$methd</span> <span style="color: rgb(51, 153, 51); ">:</span> <a href="http://www.php.net/array"><span style="color: rgb(153, 0, 0); ">Array</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(0, 0, 136); ">$tests</span> <span style="color: rgb(51, 153, 51); ">=</span> cmGn<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">where</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$methd</span><span style="color: rgb(51, 153, 51); ">,</span> <a href="http://www.php.net/create_function"><span style="color: rgb(153, 0, 0); ">create_function</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'$m'</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 255); ">'return cmTest::isTest($m);'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
 
			<span style="color: rgb(0, 0, 136); ">$this</span><span style="color: rgb(51, 153, 51); ">-></span><span style="color: rgb(0, 64, 0); ">alert</span><span style="color: rgb(0, 153, 0); ">(</span><a href="http://www.php.net/count"><span style="color: rgb(153, 0, 0); ">count</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$tests</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(51, 153, 51); ">.</span> <span style="color: rgb(0, 0, 255); ">' tests found.'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
 
			<span style="color: rgb(177, 177, 0); ">foreach</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$tests</span> <span style="color: rgb(177, 177, 0); ">as</span> <span style="color: rgb(0, 0, 136); ">$test</span><span style="color: rgb(0, 153, 0); ">)</span>
			<span style="color: rgb(0, 153, 0); ">{</span>
				try <span style="color: rgb(0, 153, 0); ">{</span>
					<span style="color: rgb(0, 0, 136); ">$this</span><span style="color: rgb(51, 153, 51); ">-></span><span style="color: rgb(0, 64, 0); ">alert</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'Performing '</span> <span style="color: rgb(51, 153, 51); ">.</span> <span style="color: rgb(0, 0, 136); ">$test</span> <span style="color: rgb(51, 153, 51); ">.</span> <span style="color: rgb(0, 0, 255); ">'...'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
					<span style="color: rgb(0, 0, 136); ">$this</span><span style="color: rgb(51, 153, 51); ">-></span><span style="color: rgb(0, 64, 0); ">testCount</span><span style="color: rgb(51, 153, 51); ">++;</span>
					<span style="color: rgb(0, 0, 136); ">$this</span><span style="color: rgb(51, 153, 51); ">-></span><span style="color: rgb(0, 0, 136); ">$test</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
					<span style="color: rgb(0, 0, 136); ">$this</span><span style="color: rgb(51, 153, 51); ">-></span><span style="color: rgb(0, 64, 0); ">passCount</span><span style="color: rgb(51, 153, 51); ">++;</span>
				<span style="color: rgb(0, 153, 0); ">}</span>
				catch <span style="color: rgb(0, 153, 0); ">(</span>Exception <span style="color: rgb(0, 0, 136); ">$e</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
					<span style="color: rgb(0, 0, 136); ">$this</span><span style="color: rgb(51, 153, 51); ">-></span><span style="color: rgb(0, 64, 0); ">alert</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$e</span><span style="color: rgb(51, 153, 51); ">-></span><span style="color: rgb(0, 64, 0); ">getMessage</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
				<span style="color: rgb(0, 153, 0); ">}</span>
			<span style="color: rgb(0, 153, 0); ">}</span>
 
			<span style="color: rgb(0, 0, 136); ">$this</span><span style="color: rgb(51, 153, 51); ">-></span><span style="color: rgb(0, 64, 0); ">alert</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$this</span><span style="color: rgb(51, 153, 51); ">-></span><span style="color: rgb(0, 64, 0); ">passCount</span> <span style="color: rgb(51, 153, 51); ">.</span> <span style="color: rgb(0, 0, 255); ">' of '</span> <span style="color: rgb(51, 153, 51); ">.</span> <span style="color: rgb(0, 0, 136); ">$this</span><span style="color: rgb(51, 153, 51); ">-></span><span style="color: rgb(0, 64, 0); ">testCount</span> <span style="color: rgb(51, 153, 51); ">.</span> <span style="color: rgb(0, 0, 255); ">' tests passed.'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">public</span> static <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> isTest<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$test</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			<span style="color: rgb(0, 0, 136); ">$strpos</span> <span style="color: rgb(51, 153, 51); ">=</span> <a href="http://www.php.net/strpos"><span style="color: rgb(153, 0, 0); ">strpos</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$test</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 255); ">'test'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(177, 177, 0); ">if</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$strpos</span> <span style="color: rgb(51, 153, 51); ">===</span> <span style="color: rgb(0, 153, 0); font-weight: bold; ">false</span><span style="color: rgb(0, 153, 0); ">)</span> 
				<span style="color: rgb(177, 177, 0); ">return</span> <span style="color: rgb(0, 153, 0); font-weight: bold; ">false</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(177, 177, 0); ">if</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$strpos</span> <span style="color: rgb(51, 153, 51); ">></span> <span style="color: rgb(204, 102, 204); ">0</span><span style="color: rgb(0, 153, 0); ">)</span> 
				<span style="color: rgb(177, 177, 0); ">return</span> <span style="color: rgb(0, 153, 0); font-weight: bold; ">false</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(177, 177, 0); ">if</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$test</span> <span style="color: rgb(51, 153, 51); ">==</span> <span style="color: rgb(0, 0, 255); ">'test'</span><span style="color: rgb(0, 153, 0); ">)</span> 
				<span style="color: rgb(177, 177, 0); ">return</span> <span style="color: rgb(0, 153, 0); font-weight: bold; ">false</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(177, 177, 0); ">return</span> <span style="color: rgb(0, 153, 0); font-weight: bold; ">true</span><span style="color: rgb(51, 153, 51); ">;</span>
		<span style="color: rgb(0, 153, 0); ">}</span>		
	<span style="color: rgb(0, 153, 0); ">}</span>
 
	<span style="color: rgb(0, 0, 0); font-weight: bold; ">class</span> cmAssert <span style="color: rgb(0, 153, 0); ">{</span>
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">public</span> static <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> failed<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$message</span> <span style="color: rgb(51, 153, 51); ">=</span> <span style="color: rgb(0, 153, 0); font-weight: bold; ">null</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			<span style="color: rgb(0, 0, 136); ">$message</span> <span style="color: rgb(51, 153, 51); ">=</span> <span style="color: rgb(0, 0, 136); ">$message</span> ? <span style="color: rgb(0, 0, 136); ">$message</span> <span style="color: rgb(51, 153, 51); ">:</span> <span style="color: rgb(0, 0, 255); ">'Assert failed called.'</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(177, 177, 0); ">throw</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">new</span> cmTestException<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$message</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(51, 153, 51); ">-</span><span style="color: rgb(204, 102, 204); ">1</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">public</span> static <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> areEqual<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$val1</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 136); ">$val2</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 136); ">$message</span> <span style="color: rgb(51, 153, 51); ">=</span> <span style="color: rgb(0, 153, 0); font-weight: bold; ">null</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			<span style="color: rgb(0, 0, 136); ">$message</span> <span style="color: rgb(51, 153, 51); ">=</span> <span style="color: rgb(0, 0, 136); ">$message</span> ? <span style="color: rgb(0, 0, 136); ">$message</span> <span style="color: rgb(51, 153, 51); ">:</span> <span style="color: rgb(0, 0, 255); ">'Assert are equal failed.'</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(177, 177, 0); ">if</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$val1</span> <span style="color: rgb(51, 153, 51); ">!==</span> <span style="color: rgb(0, 0, 136); ">$val2</span><span style="color: rgb(0, 153, 0); ">)</span>
				<span style="color: rgb(177, 177, 0); ">throw</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">new</span> cmTestException<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$message</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(51, 153, 51); ">-</span><span style="color: rgb(204, 102, 204); ">2</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">public</span> static <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> areNotEqual<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$val1</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 136); ">$val2</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 136); ">$message</span> <span style="color: rgb(51, 153, 51); ">=</span> <span style="color: rgb(0, 153, 0); font-weight: bold; ">null</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			<span style="color: rgb(0, 0, 136); ">$message</span> <span style="color: rgb(51, 153, 51); ">=</span> <span style="color: rgb(0, 0, 136); ">$message</span> ? <span style="color: rgb(0, 0, 136); ">$message</span> <span style="color: rgb(51, 153, 51); ">:</span> <span style="color: rgb(0, 0, 255); ">'Assert are not equal failed.'</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(177, 177, 0); ">if</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$val1</span> <span style="color: rgb(51, 153, 51); ">===</span> <span style="color: rgb(0, 0, 136); ">$val2</span><span style="color: rgb(0, 153, 0); ">)</span>
				<span style="color: rgb(177, 177, 0); ">throw</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">new</span> cmTestException<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$message</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(51, 153, 51); ">-</span><span style="color: rgb(204, 102, 204); ">3</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">public</span> static <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> isTrue<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$boolean</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 136); ">$message</span> <span style="color: rgb(51, 153, 51); ">=</span> <span style="color: rgb(0, 153, 0); font-weight: bold; ">null</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			<span style="color: rgb(0, 0, 136); ">$message</span> <span style="color: rgb(51, 153, 51); ">=</span> <span style="color: rgb(0, 0, 136); ">$message</span> ? <span style="color: rgb(0, 0, 136); ">$message</span> <span style="color: rgb(51, 153, 51); ">:</span> <span style="color: rgb(0, 0, 255); ">'Assert is true failed.'</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(177, 177, 0); ">if</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$boolean</span> <span style="color: rgb(51, 153, 51); ">!==</span> <span style="color: rgb(0, 153, 0); font-weight: bold; ">true</span><span style="color: rgb(0, 153, 0); ">)</span>
				<span style="color: rgb(177, 177, 0); ">throw</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">new</span> cmTestException<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$message</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(51, 153, 51); ">-</span><span style="color: rgb(204, 102, 204); ">4</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">public</span> static <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> isFalse<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$boolean</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 136); ">$message</span> <span style="color: rgb(51, 153, 51); ">=</span> <span style="color: rgb(0, 153, 0); font-weight: bold; ">null</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			<span style="color: rgb(0, 0, 136); ">$message</span> <span style="color: rgb(51, 153, 51); ">=</span> <span style="color: rgb(0, 0, 136); ">$message</span> ? <span style="color: rgb(0, 0, 136); ">$message</span> <span style="color: rgb(51, 153, 51); ">:</span> <span style="color: rgb(0, 0, 255); ">'Assert is false failed.'</span><span style="color: rgb(51, 153, 51); ">;</span>
			<span style="color: rgb(177, 177, 0); ">if</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$boolean</span> <span style="color: rgb(51, 153, 51); ">!==</span> <span style="color: rgb(0, 153, 0); font-weight: bold; ">false</span><span style="color: rgb(0, 153, 0); ">)</span>
				<span style="color: rgb(177, 177, 0); ">throw</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">new</span> cmTestException<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$message</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(51, 153, 51); ">-</span><span style="color: rgb(204, 102, 204); ">5</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
	<span style="color: rgb(0, 153, 0); ">}</span>
 
	<span style="color: rgb(0, 0, 0); font-weight: bold; ">class</span> cmException <span style="color: rgb(0, 0, 0); font-weight: bold; ">extends</span> Exception <span style="color: rgb(0, 153, 0); ">{</span>
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">const</span> baseCode <span style="color: rgb(51, 153, 51); ">=</span> <span style="color: rgb(51, 153, 51); ">-</span><span style="color: rgb(204, 102, 204); ">1064000</span><span style="color: rgb(51, 153, 51); ">;</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">public</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> __construct<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$message</span> <span style="color: rgb(51, 153, 51); ">=</span> <span style="color: rgb(0, 153, 0); font-weight: bold; ">null</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 136); ">$code</span> <span style="color: rgb(51, 153, 51); ">=</span> <span style="color: rgb(204, 102, 204); ">0</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			parent<span style="color: rgb(51, 153, 51); ">::</span>__construct<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'phpChimpanzee Exception: '</span> <span style="color: rgb(51, 153, 51); ">.</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$message</span> ? <span style="color: rgb(0, 0, 136); ">$message</span> <span style="color: rgb(51, 153, 51); ">:</span> <span style="color: rgb(0, 0, 255); ">'No message given.'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">,</span>
				 cmException<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">baseCode</span> <span style="color: rgb(51, 153, 51); ">+</span> <span style="color: rgb(0, 153, 0); ">(</span><a href="http://www.php.net/abs"><span style="color: rgb(153, 0, 0); ">abs</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$code</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(51, 153, 51); ">*</span> <span style="color: rgb(51, 153, 51); ">-</span><span style="color: rgb(204, 102, 204); ">1</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
	<span style="color: rgb(0, 153, 0); ">}</span>
 
	<span style="color: rgb(0, 0, 0); font-weight: bold; ">class</span> cmTestException <span style="color: rgb(0, 0, 0); font-weight: bold; ">extends</span> cmException <span style="color: rgb(0, 153, 0); ">{</span>
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">const</span> baseCodeModifier <span style="color: rgb(51, 153, 51); ">=</span> <span style="color: rgb(51, 153, 51); ">-</span><span style="color: rgb(204, 102, 204); ">64000</span><span style="color: rgb(51, 153, 51); ">;</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">public</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> __construct<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$message</span> <span style="color: rgb(51, 153, 51); ">=</span> <span style="color: rgb(0, 153, 0); font-weight: bold; ">null</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 136); ">$code</span> <span style="color: rgb(51, 153, 51); ">=</span> <span style="color: rgb(204, 102, 204); ">0</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			parent<span style="color: rgb(51, 153, 51); ">::</span>__construct<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 255); ">'Test failure... '</span> <span style="color: rgb(51, 153, 51); ">.</span> <span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$message</span> ? <span style="color: rgb(0, 0, 136); ">$message</span> <span style="color: rgb(51, 153, 51); ">:</span> <span style="color: rgb(0, 0, 255); ">'No message given.'</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">,</span>
				cmTestException<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">baseCodeModifier</span> <span style="color: rgb(51, 153, 51); ">+</span> <span style="color: rgb(0, 153, 0); ">(</span><a href="http://www.php.net/abs"><span style="color: rgb(153, 0, 0); ">abs</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$code</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(51, 153, 51); ">*</span> <span style="color: rgb(51, 153, 51); ">-</span><span style="color: rgb(204, 102, 204); ">1</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
	<span style="color: rgb(0, 153, 0); ">}</span>
 
	<span style="color: rgb(0, 0, 0); font-weight: bold; ">class</span> cmGnException <span style="color: rgb(0, 0, 0); font-weight: bold; ">extends</span> cmException <span style="color: rgb(0, 153, 0); ">{</span>
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">const</span> baseCodeModifier <span style="color: rgb(51, 153, 51); ">=</span> <span style="color: rgb(51, 153, 51); ">-</span><span style="color: rgb(204, 102, 204); ">128000</span><span style="color: rgb(51, 153, 51); ">;</span>
 
		<span style="color: rgb(0, 0, 0); font-weight: bold; ">public</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">function</span> __construct<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$message</span> <span style="color: rgb(51, 153, 51); ">=</span> <span style="color: rgb(0, 153, 0); font-weight: bold; ">null</span><span style="color: rgb(51, 153, 51); ">,</span> <span style="color: rgb(0, 0, 136); ">$code</span> <span style="color: rgb(51, 153, 51); ">=</span> <span style="color: rgb(204, 102, 204); ">0</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(0, 153, 0); ">{</span>
			parent<span style="color: rgb(51, 153, 51); ">::</span>__construct<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$message</span><span style="color: rgb(51, 153, 51); ">,</span>
				cmGnException<span style="color: rgb(51, 153, 51); ">::</span><span style="color: rgb(0, 64, 0); ">baseCodeModifier</span> <span style="color: rgb(51, 153, 51); ">+</span> <span style="color: rgb(0, 153, 0); ">(</span><a href="http://www.php.net/abs"><span style="color: rgb(153, 0, 0); ">abs</span></a><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 0, 136); ">$code</span><span style="color: rgb(0, 153, 0); ">)</span> <span style="color: rgb(51, 153, 51); ">*</span> <span style="color: rgb(51, 153, 51); ">-</span><span style="color: rgb(204, 102, 204); ">1</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
		<span style="color: rgb(0, 153, 0); ">}</span>
	<span style="color: rgb(0, 153, 0); ">}</span>
 
	<span style="color: rgb(0, 0, 136); ">$test</span> <span style="color: rgb(51, 153, 51); ">=</span> <span style="color: rgb(0, 0, 0); font-weight: bold; ">new</span> cmTest<span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
	<span style="color: rgb(0, 0, 136); ">$test</span><span style="color: rgb(51, 153, 51); ">-></span><span style="color: rgb(0, 64, 0); ">test</span><span style="color: rgb(0, 153, 0); ">(</span><span style="color: rgb(0, 153, 0); ">)</span><span style="color: rgb(51, 153, 51); ">;</span>
 
<span style="color: rgb(0, 0, 0); font-weight: bold; ">?></span>

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

qenn

Engineer

United States United States

Member

Follow on Twitter Follow on Twitter


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 1 Pinmemberstikves18:55 8 Jan '12  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120517.1 | Last Updated 5 Jan 2012
Article Copyright 2012 by qenn
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid