add() public method

public add ( $key, $value )
コード例 #1
0
 /**
  * {@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;
 }
コード例 #2
0
 public function testTryGetDefaultValue()
 {
     $this->coll->add('key', 'testing');
     $value = $this->coll->tryGet('key2', 'testingValue');
     $this->assertEquals('testingValue', $value);
 }
コード例 #3
0
 /**
  * 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);
 }
コード例 #4
0
ファイル: Wunderlist.php プロジェクト: italolelis/wunderlist
 /**
  * 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;
 }