1: <?php
 2: 
 3: /*
 4:  * Copyright (c) 2016 Geraldo B. Landre
 5:  * 
 6:  * See the file LICENSE for copying permission.
 7:  */
 8: 
 9: namespace pgn\tags;
10: 
11: use utils\Parser;
12: 
13: /**
14:  * @see pgn_standard.txt
15:  * @author Geraldo
16:  */
17: class Termination extends Tag {
18: 
19:     /**
20:      * @assert() === 'Termination'
21:      * @return string
22:      */
23:     public function getName() {
24:         $parsed = Parser::parseClassName(get_class());
25:         return $parsed['className'];
26:     }
27: 
28:     /**
29:      * @assert("abandoned") === true
30:      * @assert("adjudication") === true
31:      * @assert("death") === true
32:      * @assert("emergency") === true
33:      * @assert("normal") === true
34:      * @assert("rules infraction") === true
35:      * @assert("time forfeit") === true
36:      * @assert("unterminated") === true
37:      * @assert("human") === false
38:      * @assert("program") === false
39:      * @assert("person") === false
40:      * @assert("software") === false
41:      * @assert(3.1) === false
42:      * @assert("4.1.2") === false
43:      * @assert("-") === false
44:      * @assert(NULL) === false
45:      * @assert("A") === false
46:      * @assert("asdf") === false
47:      * @assert("*") === false
48:      * @param string $data
49:      * @return boolean
50:      */
51:     public function validate($data) {
52: 
53:         if (!parent::validate($data)) {
54:             return false;
55:         }
56: 
57:         return preg_match_all("/^" . self::validPattern() . "$/", $data) === 1;
58:     }
59: 
60:     /**
61:      * 
62:      * @return string Valid Regular Expression 
63:      */
64:     static public function validPattern() {
65:         return "abandoned|adjudication|death|emergency|normal|rules\sinfraction|time\sforfeit|unterminated";
66:     }
67: 
68: }
69: