Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Doctrine\DBAL\Platforms\Keywords;
4
 
5
use function array_flip;
6
use function array_map;
7
use function strtoupper;
8
 
9
/**
10
 * Abstract interface for a SQL reserved keyword dictionary.
11
 *
12
 * @psalm-consistent-constructor
13
 */
14
abstract class KeywordList
15
{
16
    /** @var string[]|null */
17
    private ?array $keywords = null;
18
 
19
    /**
20
     * Checks if the given word is a keyword of this dialect/vendor platform.
21
     *
22
     * @param string $word
23
     *
24
     * @return bool
25
     */
26
    public function isKeyword($word)
27
    {
28
        if ($this->keywords === null) {
29
            $this->initializeKeywords();
30
        }
31
 
32
        return isset($this->keywords[strtoupper($word)]);
33
    }
34
 
35
    /** @return void */
36
    protected function initializeKeywords()
37
    {
38
        $this->keywords = array_flip(array_map('strtoupper', $this->getKeywords()));
39
    }
40
 
41
    /**
42
     * Returns the list of keywords.
43
     *
44
     * @return string[]
45
     */
46
    abstract protected function getKeywords();
47
 
48
    /**
49
     * Returns the name of this keyword list.
50
     *
51
     * @deprecated
52
     *
53
     * @return string
54
     */
55
    abstract public function getName();
56
}