Example #1
0
 /**
  * @param mixed|CM_Comparable $needle
  * @param mixed|Traversable   $haystack
  * @param string              $message
  * @param boolean             $ignoreCase
  * @param boolean             $checkForObjectIdentity
  * @param bool                $checkForNonObjectIdentity
  * @throws CM_Exception_Invalid
  */
 public static function assertNotContains($needle, $haystack, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false)
 {
     if ($needle instanceof CM_Comparable) {
         if (!(is_array($haystack) || $haystack instanceof Traversable)) {
             throw new CM_Exception_Invalid('Haystack is not traversable.');
         }
         $match = false;
         foreach ($haystack as $hay) {
             if ($needle->equals($hay)) {
                 $match = true;
                 break;
             }
         }
         self::assertFalse($match, 'Needle contained.');
     } else {
         parent::assertNotContains($needle, $haystack, $message, $ignoreCase, $checkForObjectIdentity, $checkForNonObjectIdentity);
     }
 }
Example #2
0
 /**
  * @param CM_Comparable $other
  * @return boolean
  */
 public function equals(CM_Comparable $other = null)
 {
     if (empty($other)) {
         return false;
     }
     /** @var CM_File_Filesystem $other */
     if (!$this->getAdapter()->equals($other->getAdapter())) {
         return false;
     }
     /** @var CM_File_Filesystem[] $bothSecondaryList */
     $bothSecondaryList = array_merge($this->getSecondaryList(), $other->getSecondaryList());
     foreach ($bothSecondaryList as $secondary) {
         foreach (array($this->getSecondaryList(), $other->getSecondaryList()) as $secondaryList) {
             $secondaryFound = Functional\first($secondaryList, function (CM_File_Filesystem $secondaryCompare) use($secondary) {
                 return $secondaryCompare->equals($secondary);
             });
             if (!$secondaryFound) {
                 return false;
             }
         }
     }
     return true;
 }
Example #3
0
 /**
  * @param CM_Comparable $other
  * @return boolean
  */
 public function equals(CM_Comparable $other = null)
 {
     if (empty($other)) {
         return false;
     }
     /** @var CM_File $other */
     $samePath = $this->getPath() === $other->getPath();
     $sameFilesystemAdapter = $this->_filesystem->equals($other->_filesystem);
     return $samePath && $sameFilesystemAdapter;
 }
Example #4
0
 public function equals(CM_Comparable $other = null)
 {
     return $other && $this->getValue() == $other->getValue();
 }