Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format players' names (URL : 'xml_liste_joueur_o'), trim sets details, and add two Joueur() properties #17

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

StephSako
Copy link
Contributor

@StephSako StephSako commented Mar 10, 2023

This PR has several goals:

  • Add unit tests covering the function testListJoueursByClub() (URL : 'xml_liste_joueur_o'),
  • Add two properties to /Model/Player and convert the numeric fields into int value,
  • Enrich unit tests of the recovery of a match with badly formatted players in the list of club's players,
  • Format/trim player names directly at the creation of Model/Player class instances rather than during the creation of /Rencontre (else, information is not retrieved),
    image
  • As the accents are now well encoded in the response, there is no longer a need to remove accentuation on players' names at match recovery (else, information is not retrieved).
  • Don't add a 'ghost' player in RencontreDetails if he's forfeit, and return a players list empty array if the whole team is forfeit, instead of an array with only a ghost player.
    image
    image
  • Trim sets details in RencontreDetails ('ghost' set added instead),
    image
  • Format the scores of the sets into int type
    image

@StephSako StephSako changed the title Fix/format players names matches Fix/format players names (URl : 'xml_liste_joueur_o') Mar 10, 2023
@StephSako StephSako changed the title Fix/format players names (URl : 'xml_liste_joueur_o') Fix/format players names (URL : 'xml_liste_joueur_o') Mar 10, 2023
@StephSako StephSako changed the title Fix/format players names (URL : 'xml_liste_joueur_o') Format players' names (URL : 'xml_liste_joueur_o') and add two Joueur() properties Mar 10, 2023
@StephSako StephSako changed the title Format players' names (URL : 'xml_liste_joueur_o') and add two Joueur() properties Format players' names (URL : 'xml_liste_joueur_o'), trim sets details, and add two Joueur() properties Mar 11, 2023
Copy link
Owner

@alamirault alamirault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions.

Can you alse rebase/merge main ?

Comment on lines 30 to +38
foreach ($array['joueur'] as $joueur) {
$joueursA[] = [$joueur['xja'] ?: '', $joueur['xca'] ?: ''];
$joueursB[] = [$joueur['xjb'] ?: '', $joueur['xcb'] ?: ''];
$joueursA[] = ['nom' => $joueur['xja'] ?: '', 'points' => $joueur['xca'] ?: ''];
$joueursB[] = ['nom' => $joueur['xjb'] ?: '', 'points' => $joueur['xcb'] ?: ''];
}
$joueursAFormatted = $this->formatJoueurs($joueursA, $clubEquipeA);
$joueursBFormatted = $this->formatJoueurs($joueursB, $clubEquipeB);

$wholeTeamAForfeit = 0 === count(array_filter($joueursA, function ($joueurA) { return $joueurA['nom'] && $joueurA['points']; }));
$wholeTeamBForfeit = 0 === count(array_filter($joueursB, function ($joueurB) { return $joueurB['nom'] && $joueurB['points']; }));
$joueursAFormatted = !$wholeTeamAForfeit ? $this->formatJoueurs($joueursA, $clubEquipeA) : [];
$joueursBFormatted = !$wholeTeamBForfeit ? $this->formatJoueurs($joueursB, $clubEquipeB) : [];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT of this instead ?

        $wholeTeamAForfeit = true;
        $wholeTeamBForfeit = true;
        foreach ($array['joueur'] as $joueur) {
            $nomJoueurA = $joueur['xja'];
            $pointsJoueurA = $joueur['xca'];

            if($nomJoueurA && $pointsJoueurA){
                $wholeTeamAForfeit = false;
            }

            $nomJoueurB = $joueur['xjb'];
            $pointsJoueurB = $joueur['xcb'];

            if($nomJoueurB && $pointsJoueurB){
                $wholeTeamBForfeit = false;
            }

            $joueursA[] = ['nom' => $nomJoueurA, 'points' =>  $pointsJoueurA];
            $joueursB[] = ['nom' => $nomJoueurB, 'points' => $pointsJoueurB];
        }

$nomPrenom = $joueurData[0];
[$nom, $prenom] = $this->nomPrenomExtractor->extractNomPrenom($nomPrenom);
$joueurs[$this->nomPrenomExtractor->removeSeparatorsDuplication($nomPrenom)] = $this->formatJoueur($prenom, $nom, $joueurData[1], $joueursClub);
if ($joueurData['nom'] && $joueurData['points']) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in this way, we can have 4 players in left, and 3 players in right, is not a problem ?

Historically I wanted always same number of players on left and right

Comment on lines +195 to +197
$setsDetails = array_map(function ($setDetail) {
return intval($setDetail);
}, explode(' ', trim($partieData['detail'])));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like that ?

Suggested change
$setsDetails = array_map(function ($setDetail) {
return intval($setDetail);
}, explode(' ', trim($partieData['detail'])));
$setsDetails = array_map(fn (string $setDetail): int => (int) $setDetail, explode(' ', trim($partieData['detail'])));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants