mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-27 02:00:20 +02:00
24 lines
431 B
PHP
24 lines
431 B
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace DesignPatterns\Behavioral\Strategy;
|
|
|
|
class Context
|
|
{
|
|
/**
|
|
* @var Comparator
|
|
*/
|
|
private $comparator;
|
|
|
|
public function __construct(Comparator $comparator)
|
|
{
|
|
$this->comparator = $comparator;
|
|
}
|
|
|
|
public function executeStrategy(array $elements) : array
|
|
{
|
|
uasort($elements, [$this->comparator, 'compare']);
|
|
|
|
return $elements;
|
|
}
|
|
}
|