Пример #1
0
 public function rewind()
 {
     parent::rewind();
     $this->found = false;
     if (ComparisonHelper::isEquals($this->current(), $this->to)) {
         $this->found = true;
     }
 }
Пример #2
0
 /**
  * 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);
 }
 /**
  * @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
 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
 /**
  * {@inheritDoc}
  */
 public function isEqualTo($some)
 {
     return is_object($some) && $some instanceof static && ComparisonHelper::isEquals($this->get(), $some->get());
 }