4 * This file is part of the Behat.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 namespace Behat\Behat\Context\Reader;
13 use Behat\Behat\Context\Environment\ContextEnvironment;
16 * Proxies call to another reader and caches context callees for a length of an entire exercise.
18 * @author Konstantin Kudryashov <ever.zet@gmail.com>
20 final class ContextReaderCachedPerContext implements ContextReader
29 private $cachedCallees = array();
34 * @param ContextReader $childReader
36 public function __construct(ContextReader $childReader)
38 $this->childReader = $childReader;
44 public function readContextCallees(ContextEnvironment $environment, $contextClass)
46 if (isset($this->cachedCallees[$contextClass])) {
47 return $this->cachedCallees[$contextClass];
50 return $this->cachedCallees[$contextClass] = $this->childReader->readContextCallees(
51 $environment, $contextClass