add() public method

public add ( $key, $value )
 /**
  * {@inheritDoc}
  * @return $this
  */
 public function groupBy($callback)
 {
     $callback = $this->propertyExtractor($callback);
     $group = new Dictionary();
     foreach ($this as $value) {
         $key = $callback($value);
         if (!$group->containsKey($key)) {
             $element = $this instanceof VectorInterface ? new static([$value]) : new ArrayList([$value]);
             $group->add($key, $element);
         } else {
             $value = $group->get($key)->add($value);
             $group->set($key, $value);
         }
     }
     return $group;
 }
 public function testTryGetDefaultValue()
 {
     $this->coll->add('key', 'testing');
     $value = $this->coll->tryGet('key2', 'testingValue');
     $this->assertEquals('testingValue', $value);
 }
 /**
  * Adiciona uma estratégia no controlador de estratégias.
  *
  * @param $name Nome da estratégia
  * @param $strategies Array de estratégias
  */
 public function addStrategy($name, $strategies)
 {
     $this->dictionary->add($name, $strategies);
 }
Beispiel #4
0
 /**
  * Register a service
  * @param ServiceInterface $service The service object
  * @return $this
  * @throws \Collections\Exception\KeyException
  */
 public function registerService(ServiceInterface $service)
 {
     $this->services->add($service->getType(), $service);
     return $this;
 }