Maslosoft Whitelist API
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace Maslosoft\Whitelist\Tokenizer;
use Maslosoft\Whitelist\Interfaces\TokenInterface;
use Maslosoft\Whitelist\Tokenizer\Tokens\EmptyToken;
/**
* AbstractToken
*
* @author Piotr Maselkowski <pmaselkowski at gmail.com>
*/
abstract class AbstractToken
{
public $line = 0;
public $type = '';
public $name = '';
public $value = '';
/**
*
* @var TokenInterface[]
*/
protected $tokens = [];
protected $index = 0;
//abstract public function __construct(&$data, &$tokens, $index);
/**
*
* @param int $type
* @return bool
*/
public function is($type)
{
return $this->type === $type;
}
/**
*
* @param int $type
* @return bool
*/
public function not($type)
{
return $this->type !== $type;
}
/**
* Check token value
* @param string $value
*/
public function valIs($value)
{
return $this->value === $value;
}
/**
* Get token value
* @param string $value
*/
public function val()
{
return $this->value;
}
/**
* Get previous token, ignoring whitespace
* @return TokenInterface
*/
public function prev()
{
$i = $this->index - 1;
if (isset($this->tokens[$i]))
{
$token = $this->tokens[$i];
while ($token->is(T_WHITESPACE))
{
$token = $token->prev();
}
return $token;
}
return new EmptyToken();
}
/**
* Get next token, ignoring whitespace
* @return TokenInterface
*/
public function next()
{
$i = $this->index + 1;
if (isset($this->tokens[$i]))
{
$token = $this->tokens[$i];
while ($token->is(T_WHITESPACE))
{
$token = $token->next();
}
return $token;
}
return new EmptyToken();
}
}
API documentation generated by ApiGen