Example #1
0
 public static function validatePgn($pgn, $options = [])
 {
     $parsedPgn = self::parsePgn($pgn);
     $verbose = !empty($options['verbose']) ? $options['verbose'] : false;
     $chess = new self();
     // validate move first before header for quick check invalid move
     foreach ($parsedPgn['moves'] as $k => $v) {
         if ($chess->move($v) === null) {
             return false;
         }
         // quick get out if move invalid
     }
     foreach ($parsedPgn['header'] as $k => $v) {
         $chess->header($k, $v);
     }
     $parsedPgn['game'] = $chess;
     return $verbose ? $parsedPgn : true;
 }