コード例 #1
0
ファイル: TakeIterator.php プロジェクト: alexeyshockov/colada
 public function rewind()
 {
     parent::rewind();
     $this->found = false;
     if (ComparisonHelper::isEquals($this->current(), $this->to)) {
         $this->found = true;
     }
 }
コード例 #2
0
ファイル: SetBuilder.php プロジェクト: alexeyshockov/colada
 /**
  * Adds only unique elements.
  *
  * @param mixed $element
  *
  * @return \Colada\SetBuilder
  */
 public function add($element)
 {
     foreach ($this->array as $collectionElement) {
         if (ComparisonHelper::isEquals($element, $collectionElement)) {
             // Duplicate.
             return $this;
         }
     }
     return parent::add($element);
 }
コード例 #3
0
 /**
  * @param mixed $key
  *
  * @return Option
  */
 protected function getMapKey($key)
 {
     $key = $this->getObjectKey($key);
     if ($this->map->contains($key)) {
         return new Some($key);
     }
     // Search by equalable...
     foreach ($this->map as $mapKey) {
         if (ComparisonHelper::isEquals($key, $mapKey)) {
             return new Some($mapKey);
         }
     }
     return new None();
 }
コード例 #4
0
ファイル: DropIterator.php プロジェクト: alexeyshockov/colada
 public function rewind()
 {
     parent::rewind();
     $found = false;
     while ($this->valid()) {
         if (ComparisonHelper::isEquals($this->current(), $this->from)) {
             $found = true;
         }
         $this->next();
         if ($found) {
             break;
         }
     }
 }
コード例 #5
0
 protected function getMapKey($key)
 {
     if ($this->map instanceof \ArrayIterator) {
         if (!is_scalar($key)) {
             return new None();
         }
         if (isset($this->map[$key])) {
             return new Some($key);
         }
         return new None();
     }
     $key = $this->getObjectKey($key);
     if ($this->map->contains($key)) {
         return new Some($key);
     }
     // Search by equalable...
     foreach ($this->map as $mapKey) {
         if (ComparisonHelper::isEquals($key, $mapKey)) {
             return new Some($mapKey);
         }
     }
     return new None();
 }
コード例 #6
0
ファイル: Some.php プロジェクト: alexeyshockov/colada
 /**
  * {@inheritDoc}
  */
 public function isEqualTo($some)
 {
     return is_object($some) && $some instanceof static && ComparisonHelper::isEquals($this->get(), $some->get());
 }