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 ECO:
15:  * 9.4.1: Tag: ECO
16:  *
17:  * This uses a string of either the form "XDD" or the form "XDD/DD" where the "X"
18:  * is a letter from "A" to "E" and the "D" positions are digits; this is used for
19:  * an opening designation from the five volume _Encyclopedia of Chess Openings_.
20:  * This tag pair is associated with the use of the EPD opcode "eco" described in a
21:  * later section of this document.
22:  *
23:  * @see pgn_standard.txt
24:  * @author Geraldo
25:  */
26: class ECO extends Tag {
27: 
28:     public function getName() {
29:         $parsed = Parser::parseClassName(get_class());
30:         return $parsed['className'];
31:     }
32:     
33:     /**
34:      * 
35:      * @assert("A00") === true
36:      * @assert("A00/00") === true
37:      * @assert("E99") === true
38:      * @assert("E99/99") === true
39:      * @assert("C12/34") === true
40:      * @assert("C21") === true
41:      * @assert(NULL) === false
42:      * @assert("A") === false
43:      * @assert("A0") === false
44:      * @assert("A00/0") === false
45:      * @assert("asdf") === false
46:      * @assert(123) === false
47:      * @assert("*") === false
48:      * @assert("????.??.??") === false
49:      * 
50:      * @param mixed $data
51:      * @return boolean returns if a data is valid
52:      */
53:     public function validate($data) {
54:         if(!parent::validate($data)) {
55:             return false;
56:         }
57:         
58:         return preg_match_all("/^" . self::validPattern() . "$/", $data) === 1;
59:     }
60:     
61:     /**
62:      * Get the regex pattern of a valid ECO tag string
63:      * @return string regex pattern of a valid ECO tag string
64:      */
65:     static public function validPattern() {
66:         return "[A-E]\d\d(\/\d\d)?";
67:     }
68: 
69: }
70: 
API documentation generated by ApiGen