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:  * 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 Result:
13:  * The Result field value is the result of the game.  It is always exactly the 
14:  * same as the game termination marker that concludes the associated movetext.  It 
15:  * is always one of four possible values: "1-0" (White wins), "0-1" (Black wins), 
16:  * "1/2-1/2" (drawn game), and "*" (game still in progress, game abandoned, or 
17:  * result otherwise unknown).  Note that the digit zero is used in both of the 
18:  * first two cases; not the letter "O". 
19:  *  
20:  * All possible examples: 
21:  *  
22:  * [Result "0-1"] 
23:  *  
24:  * [Result "1-0"] 
25:  *  
26:  * [Result "1/2-1/2"] 
27:  *  
28:  * [Result "*"]
29:  * @see pgn_standard.txt
30:  * @author Geraldo
31:  */
32: class Result extends Tag {
33: 
34:     /**
35:      * @assert() === 'Result'
36:      * @return string Result
37:      */
38:     public function getName() {
39:         $parsed = Parser::parseClassName(get_class());
40:         return $parsed['className'];
41:     }
42:     
43:     /**
44:      * @assert ('0-1') === true
45:      * @assert ('1-0') === true
46:      * @assert ('1/2-1/2') === true
47:      * @assert ('*') === true
48:      * @assert ('O-1') === false
49:      * @assert ('1-O') === false
50:      * @assert ('0.5-0.5') === false
51:      * @assert ('?') === false
52:      * @assert ('0-10-1') === false
53:      * @assert ('0-11-0') === false
54:      * @assert ('1-00-1') === false
55:      * @assert ('1-01-0') === false
56:      * @assert ('1/2-1/21/2-1/2') === false
57:      * @assert ('**') === false
58:      * @assert ('1/2-1/2*') === false
59:      * @assert ('0-1*') === false
60:      * @param string $data
61:      * @return boolean
62:      */
63:     public function validate($data) {
64:         return parent::validate($data) && (boolean)preg_match("/^" . self::validPattern() . "$/", $data);
65:     }
66:     
67:     /**
68:      * @assert () === '*'
69:      * @return string '*'
70:      */
71:     public function getDefaultValue() {
72:         return '*';
73:     }
74:     
75:     /**
76:      * 
77:      * @return string Valid Regular Expression Pattern for PGN Results
78:      */
79:     static public function validPattern() {
80:         return "(0-1|1-0|1\/2-1\/2|\*)";
81:     }
82: }
83: 
API documentation generated by ApiGen