/** * 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); }
/** * {@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; }