first() public static method

public static first ( $obj = null, $default = null )
Beispiel #1
0
 public function test_first()
 {
     $string = 'Hello, World!';
     $this->assertEquals('H', Helper::first($string));
     $array = array(1, 2, 3);
     $this->assertEquals(1, Helper::first($array));
     $arrayIterator = new \ArrayIterator($array);
     $this->assertEquals(1, Helper::first($arrayIterator));
     $object = new \StdClass();
     $object->foo = 'foo';
     $object->bar = 'bar';
     $this->assertEquals('foo', Helper::first($object));
     $this->assertEquals(42, Helper::first(array(), 42));
 }