annotate vendor/psy/psysh/src/TabCompletion/Matcher/AbstractContextAwareMatcher.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 5fb285c0d0e3
children
rev   line source
Chris@13 1 <?php
Chris@13 2
Chris@13 3 /*
Chris@13 4 * This file is part of Psy Shell.
Chris@13 5 *
Chris@13 6 * (c) 2012-2018 Justin Hileman
Chris@13 7 *
Chris@13 8 * For the full copyright and license information, please view the LICENSE
Chris@13 9 * file that was distributed with this source code.
Chris@13 10 */
Chris@13 11
Chris@13 12 namespace Psy\TabCompletion\Matcher;
Chris@13 13
Chris@13 14 use Psy\Context;
Chris@13 15 use Psy\ContextAware;
Chris@13 16
Chris@13 17 /**
Chris@13 18 * An abstract tab completion Matcher which implements ContextAware.
Chris@13 19 *
Chris@13 20 * The AutoCompleter service will inject a Context instance into all
Chris@13 21 * ContextAware Matchers.
Chris@13 22 *
Chris@13 23 * @author Marc Garcia <markcial@gmail.com>
Chris@13 24 */
Chris@13 25 abstract class AbstractContextAwareMatcher extends AbstractMatcher implements ContextAware
Chris@13 26 {
Chris@13 27 /**
Chris@13 28 * Context instance (for ContextAware interface).
Chris@13 29 *
Chris@13 30 * @var Context
Chris@13 31 */
Chris@13 32 protected $context;
Chris@13 33
Chris@13 34 /**
Chris@13 35 * ContextAware interface.
Chris@13 36 *
Chris@13 37 * @param Context $context
Chris@13 38 */
Chris@13 39 public function setContext(Context $context)
Chris@13 40 {
Chris@13 41 $this->context = $context;
Chris@13 42 }
Chris@13 43
Chris@13 44 /**
Chris@13 45 * Get a Context variable by name.
Chris@13 46 *
Chris@13 47 * @param string $var Variable name
Chris@13 48 *
Chris@13 49 * @return mixed
Chris@13 50 */
Chris@13 51 protected function getVariable($var)
Chris@13 52 {
Chris@13 53 return $this->context->get($var);
Chris@13 54 }
Chris@13 55
Chris@13 56 /**
Chris@13 57 * Get all variables in the current Context.
Chris@13 58 *
Chris@13 59 * @return array
Chris@13 60 */
Chris@13 61 protected function getVariables()
Chris@13 62 {
Chris@13 63 return $this->context->getAll();
Chris@13 64 }
Chris@13 65 }