for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* strategy combining a set of strategies to be applied
*/
namespace Graviton\SecurityBundle\Authentication\Strategies;
use Symfony\Component\HttpFoundation\Request;
* Class MultiStrategy
*
* @package Graviton\SecurityBundle\Authentication\Strategies
* @author List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @link http://swisscom.ch
class MultiStrategy implements StrategyInterface
{
/** @var StrategyInterface[] */
protected $strategies;
* MultiStrategy constructor.
* @param StrategyInterface[] $strategies
public function __construct(array $strategies)
$this->strategies = $strategies;
}
* Applies the defined strategies on the provided request.
* @param Request $request request to handle
* @return string
public function apply(Request $request)
$exceptions = [];
foreach ($this->strategies as $strategy) {
try {
$name = $strategy->apply($request);
if ($strategy->stopPropagation()) {
return $name;
} catch ( \InvalidArgumentException $e) {
$exceptions[] = $e;
throw new \InvalidArgumentException($exceptions[0]->getMessage(), $exceptions[0]);
* Decider to stop other strategies running after from being considered.
* @return boolean
public function stopPropagation() {
return false;