Completed
Branch master (eea208)
by Toni
03:53
created
src/Context/MultilingualContext.php 1 patch
Braces   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
         $not_clean_url_language_code = substr($current_url,$base_url_length+3,2);
85 85
         if(in_array($clean_url_language_code,$this->languages_iso_codes) && substr($current_url,$base_url_length+2,1) == "/") {
86 86
             return $clean_url_language_code;
87
-        }
88
-        else if (in_array($not_clean_url_language_code,$this->languages_iso_codes) && substr($current_url,$base_url_length+5,1) == "/"){
87
+        } else if (in_array($not_clean_url_language_code,$this->languages_iso_codes) && substr($current_url,$base_url_length+5,1) == "/"){
89 88
             return $not_clean_url_language_code;
89
+        } else {
90
+            return $this->multilingual_parameters['default_language'];
90 91
         }
91
-        else return $this->multilingual_parameters['default_language'];
92 92
     }
93 93
 
94 94
     /**
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
         if(isset($this->translations[$target][$this->multilingual_parameters['default_language']])){
104 104
             $target = $this->translations[$target][$this->languageDetection()];
105 105
             return $target;
106
-        }
107
-        elseif (isset($this->translations[$target])) {
106
+        } elseif (isset($this->translations[$target])) {
108 107
             return $target;
108
+        } else {
109
+            throw new \Exception ("The text '$target'' is not defined in '$translations' translation file.");
109 110
         }
110
-        else throw new \Exception ("The text '$target'' is not defined in '$translations' translation file.");
111 111
     }
112 112
 
113 113
     /**
Please login to merge, or discard this patch.
src/Context/RawMultilingualContext.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -68,15 +68,13 @@  discard block
 block discarded – undo
68 68
         $element = $session->getPage()->find('css', $input);
69 69
         if(isset($element)) {
70 70
             $text = $element->getValue();
71
-        }
72
-        else {
71
+        } else {
73 72
             throw new \Exception(sprintf("Element is null"));
74 73
         }
75 74
 
76 75
         if($text === $value) {
77 76
             return true;
78
-        }
79
-        else {
77
+        } else {
80 78
             throw new \Exception(sprintf('Value of input : "%s" does not match the text "%s"', $text, $value));
81 79
         }
82 80
     }
@@ -90,8 +88,7 @@  discard block
 block discarded – undo
90 88
                 $this->iShouldSeeInTheSourceOfThePage($text);
91 89
                 $isTextFound = true;
92 90
                 break;
93
-            }
94
-            catch (\Exception $e) {
91
+            } catch (\Exception $e) {
95 92
                 sleep(1);
96 93
             }
97 94
         }
Please login to merge, or discard this patch.