アルゴリズムをクラスとして定義し、対象によって切り替える。 ■実装 class ItemDataContext { private $_strategy; public function __construct(ReadItemDataStrategy $strategy){ $this->_strategy = $strategy; } public function getItemData(){ return $this->strategy->getData(); } } abstract class ReadItemDataStrategy { private $_filename; public function __construct($filename) { $this->_filename = $filename; } public function getData() {