get() public method

public get ( $key )
コード例 #1
0
 /**
  * Busca por uma estratégia a partir do nome definido para a mesma.
  * @param $name
  * @return mixed
  * @throws StrategyNotFoundException
  */
 public function getStrategy($name)
 {
     if (!$this->dictionary->containsKey($name)) {
         throw new StrategyNotFoundException();
     }
     return $this->dictionary->get($name);
 }
コード例 #2
0
ファイル: Wunderlist.php プロジェクト: italolelis/wunderlist
 /**
  * @param $service
  * @return ServiceInterface
  */
 public function getService($service)
 {
     //Lazy authentication
     $token = $this->authenticationService->getAccessToken();
     if (!$token->getAccessToken()) {
         $this->authenticationService->authorize();
     }
     $this->client->createClient($this->authenticationService->getConsumerId(), $token->getAccessToken());
     return $this->services->get($service);
 }
コード例 #3
0
ファイル: Consumer.php プロジェクト: hellofresh/reagieren
 /**
  * {@inheritdoc}
  */
 public function consume($topic, callable $callback, $configs = [])
 {
     if (!$configs instanceof MapInterface) {
         $configs = new Dictionary($configs);
     }
     if (!$this->configured || $configs->get('force_config')) {
         $configs = $this->setConfig($topic, $configs);
     }
     while (true) {
         $this->fetch($topic, $callback);
     }
 }
コード例 #4
0
ファイル: Producer.php プロジェクト: hellofresh/reagieren
 /**
  * {@inheritdoc}
  */
 public function produce($payload, $configs = [])
 {
     $configs = new Dictionary($configs);
     $this->producers->each(function (ProducerInterface $producer) use($payload, $configs) {
         /** @var MapInterface $brokerConfigs */
         $brokerConfigs = $configs->get($producer->getName());
         try {
             $topic = $brokerConfigs->get('topic');
         } catch (\OutOfBoundsException $e) {
             throw new \InvalidArgumentException('You should configure the topic/exchange that you want to produce to');
         }
         $producer->produce($topic, $payload, $brokerConfigs);
     });
 }
コード例 #5
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;
 }
コード例 #6
0
ファイル: Producer.php プロジェクト: hellofresh/reagieren
 /**
  * {@inheritdoc}
  */
 public function produce($topic, $payload, $configs = [])
 {
     if (!$configs instanceof MapInterface) {
         $configs = new Dictionary($configs);
     }
     if (!$this->configured || $configs->get('force_config')) {
         $configs = $this->setConfig($topic, $configs);
     }
     $partition = $this->choosePartition($topic, isset($configs['partition_strategy']) ? $configs['partition_strategy'] : self::PARTITION_STRATEGY_RANDOM);
     if (is_string($payload)) {
         $payload = [$payload];
     }
     foreach ($payload as $message) {
         $this->connection->setMessages($topic, $partition, $message);
     }
     return $this->connection->send();
 }
コード例 #7
0
 /**
  * @expectedException \OutOfBoundsException
  */
 public function testGetInvalidItem()
 {
     $this->coll->set('keyOne', 'testing');
     $this->coll->get('keyTwo');
 }