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 utils;
10: 
11: /**
12:  * Description of String
13:  *
14:  * @author geraldo
15:  */
16: class String {
17:     // startsWith and endsWith from 
18:     // http://stackoverflow.com/questions/834303/startswith-and-endswith-functions-in-php
19: 
20:     /**
21:      * Search backwards starting from haystack length characters from the end
22:      * @assert("abcdef", "cd") == false
23:      * @assert("abcdef", "ef") == false
24:      * @assert("abcdef", "") == true
25:      * @assert("", "abcdef") == false
26:      * 
27:      * @link http://stackoverflow.com/questions/834303/startswith-and-endswith-functions-in-php font.
28:      * @param string $haystack
29:      * @param string $needle
30:      * @return bool
31:      */
32:     public static function startsWith($haystack, $needle) {
33:         return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE;
34:     }
35: 
36:     /**
37:      * Search forward starting from end minus needle length characters
38:      * 
39:      * @assert("abcdef", "ab") == false
40:      * @assert("abcdef", "cd") == false
41:      * @assert("abcdef", "ef") == true
42:      * @assert("abcdef", "") == true
43:      * @assert("", "abcdef") == false
44:      * 
45:      * @link http://stackoverflow.com/questions/834303/startswith-and-endswith-functions-in-php font.
46:      * @param string $haystack
47:      * @param string $needle
48:      * @return bool
49:      */
50:     public static function endsWith($haystack, $needle) {
51:         return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== FALSE);
52:     }
53: 
54: }
55: 
API documentation generated by ApiGen