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 utils;
 8: 
 9: /**
10:  * Designed to be a general purpose parser
11:  * 
12:  * @author Geraldo
13:  */
14: class Parser {
15: 
16:     /**
17:      * 
18:      * @param string $name name of the class, returned by get_class() function
19:      * @return array with to positions: className and namespace
20:      * @throws ParserException
21:      */
22:     static function parseClassName($name) {
23:         if (!is_array($name) && !empty($name)) {
24:             $sliceExploded = explode('\\', $name);
25:             
26:             $len = count($sliceExploded);
27:             $last = $len - 1;
28:             
29:             $array = array('className' => $sliceExploded[$last], 'namespace' => null);
30:             
31:             if($len > 1) {
32:                 $array['namespace'] = array_slice($sliceExploded, 0, -1);
33:             }
34:             
35:             return $array; 
36:         } else {
37:             throw new ParserException("Bad class name: [$name]");
38:         }
39:     }
40: }
41: 
API documentation generated by ApiGen