1: <?php
2: /*
3: * Copyright (c) 2016 Geraldo B. Landre
4: *
5: * See the file LICENSE for copying permission.
6: */
7: namespace pgn\tags;
8:
9: use utils\Parser;
10:
11: /**
12: * Description of Board:
13: * This uses an integer; this identifies the board number in a team event and also
14: * in a simultaneous exhibition.
15: * @see pgn_standard.txt
16: * @author Geraldo
17: */
18: class Board extends Tag {
19:
20: public function getName() {
21: $parsed = Parser::parseClassName(get_class());
22: return $parsed['className'];
23: }
24:
25: /**
26: * @assert("1") === true
27: * @assert("19") === true
28: * @assert(1) === true
29: * @assert("3.1") === false
30: * @assert(3.1) === false
31: * @assert("4.1.2") === false
32: * @assert("-") === false
33: * @assert("?") === true
34: * @assert(NULL) === false
35: * @assert("A") === false
36: * @assert("asdf") === false
37: * @assert("*") === false
38: * @assert("????.??.??") === false
39: * @param string $data
40: * @return boolean
41: */
42: public function validate($data) {
43:
44: if(!parent::validate($data)) {
45: return false;
46: }
47:
48: if($data === '?') {
49: return true;
50: }
51:
52: return preg_match_all("/^" . self::validPattern() . "$/", $data) === 1;
53: }
54:
55: /**
56: *
57: * @return string Valid Regular Expression Pattern for PGN Rounds
58: */
59: static public function validPattern() {
60: return "\d+";
61: }
62:
63: }
64: