notEmpty() public static method

More sane !empty() method to not false positive '0' (0 as string) as empty.
public static notEmpty ( mixed $value ) : boolean
$value mixed
return boolean
示例#1
0
 /**
  * @return void
  */
 public function testNotEmpty()
 {
     $res = Utility::notEmpty('a');
     $this->assertTrue($res);
     $res = Utility::notEmpty(2);
     $this->assertTrue($res);
     $res = Utility::notEmpty(0);
     $this->assertFalse($res);
     $res = Utility::notEmpty('0');
     $this->assertTrue($res);
     $res = Utility::notEmpty(null);
     $this->assertFalse($res);
     $res = Utility::notEmpty(false);
     $this->assertFalse($res);
     $res = Utility::notEmpty('');
     $this->assertFalse($res);
     $res = Utility::notEmpty([]);
     $this->assertFalse($res);
 }