logicalAnd() 공개 정적인 메소드

Returns true only if all values are true.
public static logicalAnd ( array $array ) : boolean
$array array
리턴 boolean Result
예제 #1
0
 /**
  * UtilityTest::testLogicalAnd()
  *
  * @covers ::logicalAnd
  * @return void
  */
 public function testLogicalAnd()
 {
     $array = ['a' => 1, 'b' => 1, 'c' => 0, 'd' => 1];
     $is = Utility::logicalAnd($array);
     $this->assertFalse($is);
     $array = ['a' => 1, 'b' => 1, 'c' => 1, 'd' => 1];
     $is = Utility::logicalAnd($array);
     $this->assertTrue($is);
 }
예제 #2
0
 /**
  * On non-transaction db connections it will return a deep array of bools instead of bool.
  * So we need to call this method inside the modified saveAll() method to return the expected single bool there, too.
  *
  * @param array
  * @return bool
  * @deprecated Not sure this is useful for CakePHP 3.0
  */
 public static function isValidSaveAll($array)
 {
     if (empty($array)) {
         return false;
     }
     $ret = true;
     foreach ($array as $key => $val) {
         if (is_array($val)) {
             $ret = $ret & Utility::logicalAnd($val);
         } else {
             $ret = $ret & $val;
         }
     }
     return (bool) $ret;
 }