<?php
namespace Fifa\ConnectId\Command\BulkRegistration\Helpers;

/**
 * Class LocalDatabase
 */
class LocalDatabase
{
    /**
     * Collection that contains a sample list of not registered players
     * @var array
     */
    private static $data = [
        ['Andre', 'Spidle'],
        ['Dewitt', 'Eatmon'],
        ['Carmen', 'Lesley'],
        ['Antione', 'Darley'],
        ['Marshall', 'Seymore'],
        ['Britt', 'Roussel'],
        ['Clinton', 'Marcellus'],
        ['Lindsey', 'Compton'],
        ['Quinton', 'Monteiro'],
        ['Thomas', 'Hernandez'],
        ['Numbers', 'Ridder'],
        ['Chad', 'Brabant'],
        ['Sang', 'Matos'],
        ['Parker', 'Crosier'],
        ['Norman', 'Dubuisson'],
        ['Isaiah', 'Buckelew'],
        ['Lawrence', 'Bell'],
        ['Alfred', 'Glasgow'],
        ['Neil', 'Chesney'],
        ['Damien', 'Venable'],
    ];

    /**
     * @param string $lastNameStartChar
     * @param string $lastNameEndCharacter
     * @return array
     */
    public function getNotRegisteredPlayersRange($lastNameStartChar, $lastNameEndCharacter)
    {
        $lastNameStartChar = strtolower($lastNameStartChar);
        $lastNameEndCharacter = strtolower($lastNameEndCharacter);

        $playersRange = [];
        foreach (self::$data as $player) {

            $playerLastNameFirstLetter = strtolower(substr($player[1], 0, 1));
            if (strcmp($playerLastNameFirstLetter, $lastNameStartChar) >= 0 && strcmp($playerLastNameFirstLetter, $lastNameEndCharacter) <= 0) {
                $playersRange[] = $player;
            }
        }

        return $playersRange;
    }

    /**
     * @param array $player
     * @param string $fifaUniqueId
     */
    public function updateFifaUniqueId($player, $fifaUniqueId)
    {
        // update ID in database
    }
}