From 1224684f8be672cf8a7daf5d83aee4c9d1404bd2 Mon Sep 17 00:00:00 2001 From: Patrick BRUGIERE Date: Wed, 25 Oct 2023 10:53:15 +0200 Subject: [PATCH] ajout dans la classe vocabulary --- Project/php/model/Vocabulary.php | 113 +++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100755 Project/php/model/Vocabulary.php diff --git a/Project/php/model/Vocabulary.php b/Project/php/model/Vocabulary.php new file mode 100755 index 0000000..305c194 --- /dev/null +++ b/Project/php/model/Vocabulary.php @@ -0,0 +1,113 @@ + "eng" + ); + protected String $nom; + protected String $image; + protected String $theme; + + /** + * @param string[] $map + * @param String $nom + * @param String $image + * @param String $theme + */ + public function __construct(array $map, $nom, $image, $theme) + { + $this->map = $map; + $this->nom = $nom; + $this->image = $image; + $this->theme = $theme; + } + + + public function translateToEnglish($fr) { + return isset($this->map[$fr]) ? $this->map[$fr] : $fr; + } + + public function translateToFrench($eng) { + // Chercher la clé correspondante pour la valeur en anglais + $key = array_search($eng, $this->map); + + // Si la traduction est trouvée, retourner la clé (en français) + return $key !== false ? $key : $eng; + } + + public function addTranslation($fr, $eng) { + $this->map[$fr] = $eng; + } + + /** + * @return string[] + */ + public function getMap() + { + return $this->map; + } + + /** + * @return String + */ + public function getNom() + { + return $this->nom; + } + + /** + * @return String + */ + public function getImage() + { + return $this->image; + } + + /** + * @return String + */ + public function getTheme() + { + return $this->theme; + } + + /** + * @param string[] $map + */ + public function setMap($map) + { + $this->map = $map; + } + + /** + * @param String $nom + */ + public function setNom($nom) + { + $this->nom = $nom; + } + + /** + * @param String $image + */ + public function setImage($image) + { + $this->image = $image; + } + + /** + * @param String $theme + */ + public function setTheme($theme) + { + $this->theme = $theme; + } + + + + +} +