Overview

Namespaces

  • pgn
    • exceptions
    • tags
  • utils

Classes

  • pgn\Game
  • pgn\PGN
  • pgn\tags\Annotator
  • pgn\tags\Black
  • pgn\tags\BlackElo
  • pgn\tags\BlackNA
  • pgn\tags\BlackTitle
  • pgn\tags\BlackType
  • pgn\tags\BlackUSCF
  • pgn\tags\Board
  • pgn\tags\Date
  • pgn\tags\ECO
  • pgn\tags\Event
  • pgn\tags\EventCountry
  • pgn\tags\EventDate
  • pgn\tags\EventRounds
  • pgn\tags\EventSponsor
  • pgn\tags\EventType
  • pgn\tags\FEN
  • pgn\tags\Mode
  • pgn\tags\NIC
  • pgn\tags\Opening
  • pgn\tags\PlyCount
  • pgn\tags\Result
  • pgn\tags\Round
  • pgn\tags\Section
  • pgn\tags\SetUp
  • pgn\tags\Site
  • pgn\tags\Source
  • pgn\tags\SourceDate
  • pgn\tags\Stage
  • pgn\tags\SubVariation
  • pgn\tags\Tag
  • pgn\tags\Termination
  • pgn\tags\Time
  • pgn\tags\TimeControl
  • pgn\tags\UknownTag
  • pgn\tags\UTCDate
  • pgn\tags\UTCTime
  • pgn\tags\Variation
  • pgn\tags\White
  • pgn\tags\WhiteElo
  • pgn\tags\WhiteNA
  • pgn\tags\WhiteTitle
  • pgn\tags\WhiteType
  • pgn\tags\WhiteUSCF
  • utils\Parser
  • utils\String

Exceptions

  • pgn\exceptions\InvalidClassNameException
  • pgn\exceptions\InvalidDataException
  • pgn\exceptions\InvalidGameFormatException
  • pgn\exceptions\InvalidGamePathException
  • pgn\exceptions\PGNException
  • utils\ParserException
  • Overview
  • Namespace
  • Class
 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:  * Description of Time:
15:  *
16:  * This uses a time-of-day value in the form "HH:MM:SS"; similar to the Date tag
17:  * except that it denotes the local clock time (hours, minutes, and seconds) of
18:  * the start of the game.  Note that colons, not periods, are used for field
19:  * separators for the Time tag value.  The value is taken from the local time
20:  * corresponding to the location given in the Site tag pair.
21:  *
22:  * @see pgn_standard.txt
23:  * @author Geraldo
24:  */
25: class TimeControl extends Tag {
26: 
27:     public function getName() {
28:         $parsed = Parser::parseClassName(get_class());
29:         return $parsed['className'];
30:     }
31: 
32:     /**
33:      * 
34:      * @assert("?") === true
35:      * @assert("-") === true
36:      * @assert("32/45") === true
37:      * @assert("40/9000") === true
38:      * @assert("300") === true
39:      * @assert("35+5") === true
40:      * @assert("*35") === true
41:      * @assert("-:40/9000:30/3000:15/30000:300") === true
42:      * @assert("-:40/9000:30/3000:15/30000:*35") === true
43:      * @assert("-:40/9000:*35:40/9000:300") === true
44:      * @assert("32/45:300") === true
45:      * @assert("?:-:40/9000:300:300:*35") === false
46:      * @assert("123,45") === false
47:      * @assert("22/35.-") === false
48:      * @assert("??.??") === false
49:      * @assert("?.-") === false
50:      * @assert("asdf") === false
51:      * @assert(2) === true
52:      * @assert("a") === false
53:      * @assert(NULL) === false
54:      * 
55:      * @todo("300:300:*35:40/9000:-") === false
56:      * @todo("00/300:?") === false
57:      * @todo("00/300:-") === false
58:      * @todo("-:40/9000:*35:40/9000:300") === false
59:      * @todo("300:300:*35") === false
60:      * 
61:      * @param mixed $data
62:      * @return boolean returns if a data is valid
63:      */
64:     public function validate($data) {
65:         if (!parent::validate($data)) {
66:             return false;
67:         }
68: 
69:         return preg_match_all("/^" . self::validPattern() . "$/", $data) === 1;
70:     }
71: 
72:     /**
73:      * Get the regex pattern of a valid FEN tag string
74:      * @return string regex pattern of a valid SetUp tag string
75:      */
76:     static public function validPattern() {
77:         return "(\?|-|\d+\/\d+|\*\d+|\d+\+\d+|\d+)(:(\?|-|\d+\/\d+|\d+\+\d+|\d+|\*\d+)){0,4}";
78:     }
79: 
80: }
81: 
API documentation generated by ApiGen