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 SetUp:
15:  * This tag takes an integer that denotes the "set-up" status of the game.  A
16:  * value of "0" indicates that the game has started from the usual initial array.
17:  * A value of "1" indicates that the game started from a set-up position; this
18:  * position is given in the "FEN" tag pair.  This tag must appear for a game
19:  * starting with a set-up position.  If it appears with a tag value of "1", a FEN
20:  * tag pair must also appear.
21:  * @see pgn_standard.txt
22:  * @author Geraldo
23:  */
24: class SetUp extends Tag {
25: 
26:     public function getName() {
27:         $parsed = Parser::parseClassName(get_class());
28:         return $parsed['className'];
29:     }
30: 
31:     /**
32:      * 
33:      * @assert("") === true
34:      * @assert("0") === true
35:      * @assert("1") === true
36:      * @assert("-1") === false
37:      * @assert("2") === false
38:      * @assert("a") === false
39:      * @assert(NULL) === false
40:      * @assert("A") === false
41:      * @assert("*") === false
42:      * @assert("2.1") === false
43:      * 
44:      * @param mixed $data
45:      * @return boolean returns if a data is valid
46:      */
47:     public function validate($data) {
48:         if (!parent::validate($data)) {
49:             return false;
50:         }
51: 
52:         return preg_match_all("/^" . self::validPattern() . "$/", $data) === 1;
53:     }
54:     
55:     /**
56:      * Get the regex pattern of a valid SetUp tag string
57:      * @return string regex pattern of a valid SetUp tag string
58:      */
59:     static public function validPattern() {
60:         return "[0|1]";
61:     }
62: 
63: }
64: 
API documentation generated by ApiGen