Completed
Push — develop ( a51f26...2ecf95 )
by Zack
15:32
created
vendor/gettext/gettext/src/Utils/ParsedComment.php 3 patches
Indentation   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -7,134 +7,134 @@
 block discarded – undo
7 7
  */
8 8
 class ParsedComment
9 9
 {
10
-    /**
11
-     * The comment itself.
12
-     *
13
-     * @var string
14
-     */
15
-    protected $comment;
16
-
17
-    /**
18
-     * The line where the comment starts.
19
-     *
20
-     * @var int
21
-     */
22
-    protected $firstLine;
23
-
24
-    /**
25
-     * The line where the comment ends.
26
-     *
27
-     * @var int
28
-     */
29
-    protected $lastLine;
30
-
31
-    /**
32
-     * Initializes the instance.
33
-     *
34
-     * @param string $comment The comment itself.
35
-     * @param int    $firstLine The line where the comment starts.
36
-     * @param int    $lastLine The line where the comment ends.
37
-     */
38
-    public function __construct($comment, $firstLine, $lastLine)
39
-    {
40
-        $this->comment = $comment;
41
-        $this->firstLine = $firstLine;
42
-        $this->lastLine = $lastLine;
43
-    }
44
-
45
-    /**
46
-     * Create new object from raw comment data.
47
-     *
48
-     * @param string $value The PHP comment string.
49
-     * @param int $line The line where the comment starts.
50
-     *
51
-     * @return static The parsed comment.
52
-     */
53
-    public static function create($value, $line)
54
-    {
55
-        $lastLine = $line + substr_count($value, "\n");
56
-
57
-        $lines = array_map(function ($line) {
58
-            if ('' === trim($line)) {
59
-                return null;
60
-            }
61
-
62
-            $line = ltrim($line, "#*/ \t");
63
-            $line = rtrim($line, "#*/ \t");
64
-
65
-            return trim($line);
66
-        }, explode("\n", $value));
67
-
68
-        // Remove empty lines.
69
-        $lines = array_filter($lines);
70
-        $value = implode(' ', $lines);
71
-
72
-        return new static($value, $line, $lastLine);
73
-    }
74
-
75
-    /**
76
-     * Return the line where the comment starts.
77
-     *
78
-     * @return int Line number.
79
-     */
80
-    public function getFirstLine()
81
-    {
82
-        return $this->firstLine;
83
-    }
84
-
85
-    /**
86
-     * Return the line where the comment ends.
87
-     *
88
-     * @return int Line number.
89
-     */
90
-    public function getLastLine()
91
-    {
92
-        return $this->lastLine;
93
-    }
94
-
95
-    /**
96
-     * Return the actual comment string.
97
-     *
98
-     * @return string The comment.
99
-     */
100
-    public function getComment()
101
-    {
102
-        return $this->comment;
103
-    }
104
-
105
-    /**
106
-     * Whether this comment is related with a given function.
107
-     *
108
-     * @param ParsedFunction $function The function to check.
109
-     * @return bool Whether the comment is related or not.
110
-     */
111
-    public function isRelatedWith(ParsedFunction $function)
112
-    {
113
-        return $this->getLastLine() === $function->getLine() || $this->getLastLine() === $function->getLine() - 1;
114
-    }
115
-
116
-    /**
117
-     * Whether the comment matches the required prefixes.
118
-     *
119
-     * @param array $prefixes An array of prefixes to check.
120
-     * @return bool Whether the comment matches the prefixes or not.
121
-     */
122
-    public function checkPrefixes(array $prefixes)
123
-    {
124
-        if ('' === $this->comment) {
125
-            return false;
126
-        }
127
-
128
-        if (empty($prefixes)) {
129
-            return true;
130
-        }
131
-
132
-        foreach ($prefixes as $prefix) {
133
-            if (strpos($this->comment, $prefix) === 0) {
134
-                return true;
135
-            }
136
-        }
137
-
138
-        return false;
139
-    }
10
+	/**
11
+	 * The comment itself.
12
+	 *
13
+	 * @var string
14
+	 */
15
+	protected $comment;
16
+
17
+	/**
18
+	 * The line where the comment starts.
19
+	 *
20
+	 * @var int
21
+	 */
22
+	protected $firstLine;
23
+
24
+	/**
25
+	 * The line where the comment ends.
26
+	 *
27
+	 * @var int
28
+	 */
29
+	protected $lastLine;
30
+
31
+	/**
32
+	 * Initializes the instance.
33
+	 *
34
+	 * @param string $comment The comment itself.
35
+	 * @param int    $firstLine The line where the comment starts.
36
+	 * @param int    $lastLine The line where the comment ends.
37
+	 */
38
+	public function __construct($comment, $firstLine, $lastLine)
39
+	{
40
+		$this->comment = $comment;
41
+		$this->firstLine = $firstLine;
42
+		$this->lastLine = $lastLine;
43
+	}
44
+
45
+	/**
46
+	 * Create new object from raw comment data.
47
+	 *
48
+	 * @param string $value The PHP comment string.
49
+	 * @param int $line The line where the comment starts.
50
+	 *
51
+	 * @return static The parsed comment.
52
+	 */
53
+	public static function create($value, $line)
54
+	{
55
+		$lastLine = $line + substr_count($value, "\n");
56
+
57
+		$lines = array_map(function ($line) {
58
+			if ('' === trim($line)) {
59
+				return null;
60
+			}
61
+
62
+			$line = ltrim($line, "#*/ \t");
63
+			$line = rtrim($line, "#*/ \t");
64
+
65
+			return trim($line);
66
+		}, explode("\n", $value));
67
+
68
+		// Remove empty lines.
69
+		$lines = array_filter($lines);
70
+		$value = implode(' ', $lines);
71
+
72
+		return new static($value, $line, $lastLine);
73
+	}
74
+
75
+	/**
76
+	 * Return the line where the comment starts.
77
+	 *
78
+	 * @return int Line number.
79
+	 */
80
+	public function getFirstLine()
81
+	{
82
+		return $this->firstLine;
83
+	}
84
+
85
+	/**
86
+	 * Return the line where the comment ends.
87
+	 *
88
+	 * @return int Line number.
89
+	 */
90
+	public function getLastLine()
91
+	{
92
+		return $this->lastLine;
93
+	}
94
+
95
+	/**
96
+	 * Return the actual comment string.
97
+	 *
98
+	 * @return string The comment.
99
+	 */
100
+	public function getComment()
101
+	{
102
+		return $this->comment;
103
+	}
104
+
105
+	/**
106
+	 * Whether this comment is related with a given function.
107
+	 *
108
+	 * @param ParsedFunction $function The function to check.
109
+	 * @return bool Whether the comment is related or not.
110
+	 */
111
+	public function isRelatedWith(ParsedFunction $function)
112
+	{
113
+		return $this->getLastLine() === $function->getLine() || $this->getLastLine() === $function->getLine() - 1;
114
+	}
115
+
116
+	/**
117
+	 * Whether the comment matches the required prefixes.
118
+	 *
119
+	 * @param array $prefixes An array of prefixes to check.
120
+	 * @return bool Whether the comment matches the prefixes or not.
121
+	 */
122
+	public function checkPrefixes(array $prefixes)
123
+	{
124
+		if ('' === $this->comment) {
125
+			return false;
126
+		}
127
+
128
+		if (empty($prefixes)) {
129
+			return true;
130
+		}
131
+
132
+		foreach ($prefixes as $prefix) {
133
+			if (strpos($this->comment, $prefix) === 0) {
134
+				return true;
135
+			}
136
+		}
137
+
138
+		return false;
139
+	}
140 140
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      * @param int    $firstLine The line where the comment starts.
36 36
      * @param int    $lastLine The line where the comment ends.
37 37
      */
38
-    public function __construct($comment, $firstLine, $lastLine)
38
+    public function __construct( $comment, $firstLine, $lastLine )
39 39
     {
40 40
         $this->comment = $comment;
41 41
         $this->firstLine = $firstLine;
@@ -50,26 +50,26 @@  discard block
 block discarded – undo
50 50
      *
51 51
      * @return static The parsed comment.
52 52
      */
53
-    public static function create($value, $line)
53
+    public static function create( $value, $line )
54 54
     {
55
-        $lastLine = $line + substr_count($value, "\n");
55
+        $lastLine = $line + substr_count( $value, "\n" );
56 56
 
57
-        $lines = array_map(function ($line) {
58
-            if ('' === trim($line)) {
57
+        $lines = array_map( function( $line ) {
58
+            if ( '' === trim( $line ) ) {
59 59
                 return null;
60 60
             }
61 61
 
62
-            $line = ltrim($line, "#*/ \t");
63
-            $line = rtrim($line, "#*/ \t");
62
+            $line = ltrim( $line, "#*/ \t" );
63
+            $line = rtrim( $line, "#*/ \t" );
64 64
 
65
-            return trim($line);
66
-        }, explode("\n", $value));
65
+            return trim( $line );
66
+        }, explode( "\n", $value ) );
67 67
 
68 68
         // Remove empty lines.
69
-        $lines = array_filter($lines);
70
-        $value = implode(' ', $lines);
69
+        $lines = array_filter( $lines );
70
+        $value = implode( ' ', $lines );
71 71
 
72
-        return new static($value, $line, $lastLine);
72
+        return new static( $value, $line, $lastLine );
73 73
     }
74 74
 
75 75
     /**
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
      * @param ParsedFunction $function The function to check.
109 109
      * @return bool Whether the comment is related or not.
110 110
      */
111
-    public function isRelatedWith(ParsedFunction $function)
111
+    public function isRelatedWith( ParsedFunction $function )
112 112
     {
113 113
         return $this->getLastLine() === $function->getLine() || $this->getLastLine() === $function->getLine() - 1;
114 114
     }
@@ -119,18 +119,18 @@  discard block
 block discarded – undo
119 119
      * @param array $prefixes An array of prefixes to check.
120 120
      * @return bool Whether the comment matches the prefixes or not.
121 121
      */
122
-    public function checkPrefixes(array $prefixes)
122
+    public function checkPrefixes( array $prefixes )
123 123
     {
124
-        if ('' === $this->comment) {
124
+        if ( '' === $this->comment ) {
125 125
             return false;
126 126
         }
127 127
 
128
-        if (empty($prefixes)) {
128
+        if ( empty( $prefixes ) ) {
129 129
             return true;
130 130
         }
131 131
 
132
-        foreach ($prefixes as $prefix) {
133
-            if (strpos($this->comment, $prefix) === 0) {
132
+        foreach ( $prefixes as $prefix ) {
133
+            if ( strpos( $this->comment, $prefix ) === 0 ) {
134 134
                 return true;
135 135
             }
136 136
         }
Please login to merge, or discard this patch.
Braces   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -5,8 +5,7 @@  discard block
 block discarded – undo
5 5
 /**
6 6
  * Comment parsed by PhpFunctionsScanner.
7 7
  */
8
-class ParsedComment
9
-{
8
+class ParsedComment {
10 9
     /**
11 10
      * The comment itself.
12 11
      *
@@ -35,8 +34,7 @@  discard block
 block discarded – undo
35 34
      * @param int    $firstLine The line where the comment starts.
36 35
      * @param int    $lastLine The line where the comment ends.
37 36
      */
38
-    public function __construct($comment, $firstLine, $lastLine)
39
-    {
37
+    public function __construct($comment, $firstLine, $lastLine) {
40 38
         $this->comment = $comment;
41 39
         $this->firstLine = $firstLine;
42 40
         $this->lastLine = $lastLine;
@@ -50,8 +48,7 @@  discard block
 block discarded – undo
50 48
      *
51 49
      * @return static The parsed comment.
52 50
      */
53
-    public static function create($value, $line)
54
-    {
51
+    public static function create($value, $line) {
55 52
         $lastLine = $line + substr_count($value, "\n");
56 53
 
57 54
         $lines = array_map(function ($line) {
@@ -77,8 +74,7 @@  discard block
 block discarded – undo
77 74
      *
78 75
      * @return int Line number.
79 76
      */
80
-    public function getFirstLine()
81
-    {
77
+    public function getFirstLine() {
82 78
         return $this->firstLine;
83 79
     }
84 80
 
@@ -87,8 +83,7 @@  discard block
 block discarded – undo
87 83
      *
88 84
      * @return int Line number.
89 85
      */
90
-    public function getLastLine()
91
-    {
86
+    public function getLastLine() {
92 87
         return $this->lastLine;
93 88
     }
94 89
 
@@ -97,8 +92,7 @@  discard block
 block discarded – undo
97 92
      *
98 93
      * @return string The comment.
99 94
      */
100
-    public function getComment()
101
-    {
95
+    public function getComment() {
102 96
         return $this->comment;
103 97
     }
104 98
 
@@ -108,8 +102,7 @@  discard block
 block discarded – undo
108 102
      * @param ParsedFunction $function The function to check.
109 103
      * @return bool Whether the comment is related or not.
110 104
      */
111
-    public function isRelatedWith(ParsedFunction $function)
112
-    {
105
+    public function isRelatedWith(ParsedFunction $function) {
113 106
         return $this->getLastLine() === $function->getLine() || $this->getLastLine() === $function->getLine() - 1;
114 107
     }
115 108
 
@@ -119,8 +112,7 @@  discard block
 block discarded – undo
119 112
      * @param array $prefixes An array of prefixes to check.
120 113
      * @return bool Whether the comment matches the prefixes or not.
121 114
      */
122
-    public function checkPrefixes(array $prefixes)
123
-    {
115
+    public function checkPrefixes(array $prefixes) {
124 116
         if ('' === $this->comment) {
125 117
             return false;
126 118
         }
Please login to merge, or discard this patch.
vendor/gettext/gettext/src/Utils/FunctionsScanner.php 3 patches
Indentation   +171 added lines, -171 removed lines patch added patch discarded remove patch
@@ -7,175 +7,175 @@
 block discarded – undo
7 7
 
8 8
 abstract class FunctionsScanner
9 9
 {
10
-    /**
11
-     * Scan and returns the functions and the arguments.
12
-     *
13
-     * @param array $constants Constants used in the code to replace
14
-     *
15
-     * @return array
16
-     */
17
-    abstract public function getFunctions(array $constants = []);
18
-
19
-    /**
20
-     * Search for specific functions and create translations.
21
-     *
22
-     * You can pass multiple translation with different domains and value found will be sorted respectively.
23
-     *
24
-     * @param Translations|Translations[] $translations Multiple domain translations instances where to save the values
25
-     * @param array $options The extractor options
26
-     * @throws Exception
27
-     */
28
-    public function saveGettextFunctions($translations, array $options)
29
-    {
30
-        $translations = is_array($translations) ? $translations : [$translations];
31
-
32
-        /** @var Translations[] $translationByDomain [domain => translations, ..] */
33
-        $translationByDomain = array_reduce($translations, function ($carry, Translations $translations) {
34
-            $carry[$translations->getDomain()] = $translations;
35
-            return $carry;
36
-        }, []);
37
-
38
-        $functions = $options['functions'];
39
-        $file = $options['file'];
40
-
41
-        /**
42
-         * List of source code comments already associated with a function.
43
-         *
44
-         * Prevents associating the same comment to multiple functions.
45
-         *
46
-         * @var ParsedComment[] $commentsCache
47
-         */
48
-        $commentsCache = [];
49
-
50
-        foreach ($this->getFunctions($options['constants']) as $function) {
51
-            list($name, $line, $args) = $function;
52
-
53
-            if (isset($options['lineOffset'])) {
54
-                $line += $options['lineOffset'];
55
-            }
56
-
57
-            if (!isset($functions[$name])) {
58
-                continue;
59
-            }
60
-
61
-            $deconstructed = $this->deconstructArgs($functions[$name], $args);
62
-
63
-            if (!$deconstructed) {
64
-                continue;
65
-            }
66
-
67
-            list($domain, $context, $original, $plural) = $deconstructed;
68
-
69
-            if ((string)$original === '') {
70
-                continue;
71
-            }
72
-
73
-            $isDefaultDomain = $domain === null;
74
-
75
-            $domainTranslations = isset($translationByDomain[$domain]) ? $translationByDomain[$domain] : false;
76
-
77
-            if (!empty($options['domainOnly']) && $isDefaultDomain) {
78
-                // If we want to find translations for a specific domain, skip default domain messages
79
-                continue;
80
-            }
81
-
82
-            if (!$domainTranslations) {
83
-                continue;
84
-            }
85
-
86
-            $translation = $domainTranslations->insert($context, $original, $plural);
87
-            $translation->addReference($file, $line);
88
-
89
-            if (isset($function[3])) {
90
-                /* @var ParsedComment $extractedComment */
91
-                foreach ($function[3] as $extractedComment) {
92
-                    if (in_array($extractedComment, $commentsCache, true)) {
93
-                        continue;
94
-                    }
95
-                    $translation->addExtractedComment($extractedComment->getComment());
96
-                    $commentsCache[] = $extractedComment;
97
-                }
98
-            }
99
-        }
100
-    }
101
-
102
-    /**
103
-     * Deconstruct arguments to translation values
104
-     *
105
-     * @param $function
106
-     * @param $args
107
-     * @return array|null
108
-     * @throws Exception
109
-     */
110
-    protected function deconstructArgs($function, $args)
111
-    {
112
-        $domain = null;
113
-        $context = null;
114
-        $original = null;
115
-        $plural = null;
116
-
117
-        switch ($function) {
118
-            case 'noop':
119
-            case 'gettext':
120
-                if (!isset($args[0])) {
121
-                    return null;
122
-                }
123
-
124
-                $original = $args[0];
125
-                break;
126
-            case 'ngettext':
127
-                if (!isset($args[1])) {
128
-                    return null;
129
-                }
130
-
131
-                list($original, $plural) = $args;
132
-                break;
133
-            case 'pgettext':
134
-                if (!isset($args[1])) {
135
-                    return null;
136
-                }
137
-
138
-                list($context, $original) = $args;
139
-                break;
140
-            case 'dgettext':
141
-                if (!isset($args[1])) {
142
-                    return null;
143
-                }
144
-
145
-                list($domain, $original) = $args;
146
-                break;
147
-            case 'dpgettext':
148
-                if (!isset($args[2])) {
149
-                    return null;
150
-                }
151
-
152
-                list($domain, $context, $original) = $args;
153
-                break;
154
-            case 'npgettext':
155
-                if (!isset($args[2])) {
156
-                    return null;
157
-                }
158
-
159
-                list($context, $original, $plural) = $args;
160
-                break;
161
-            case 'dnpgettext':
162
-                if (!isset($args[3])) {
163
-                    return null;
164
-                }
165
-
166
-                list($domain, $context, $original, $plural) = $args;
167
-                break;
168
-            case 'dngettext':
169
-                if (!isset($args[2])) {
170
-                    return null;
171
-                }
172
-
173
-                list($domain, $original, $plural) = $args;
174
-                break;
175
-            default:
176
-                throw new Exception(sprintf('Not valid function %s', $function));
177
-        }
178
-
179
-        return [$domain, $context, $original, $plural];
180
-    }
10
+	/**
11
+	 * Scan and returns the functions and the arguments.
12
+	 *
13
+	 * @param array $constants Constants used in the code to replace
14
+	 *
15
+	 * @return array
16
+	 */
17
+	abstract public function getFunctions(array $constants = []);
18
+
19
+	/**
20
+	 * Search for specific functions and create translations.
21
+	 *
22
+	 * You can pass multiple translation with different domains and value found will be sorted respectively.
23
+	 *
24
+	 * @param Translations|Translations[] $translations Multiple domain translations instances where to save the values
25
+	 * @param array $options The extractor options
26
+	 * @throws Exception
27
+	 */
28
+	public function saveGettextFunctions($translations, array $options)
29
+	{
30
+		$translations = is_array($translations) ? $translations : [$translations];
31
+
32
+		/** @var Translations[] $translationByDomain [domain => translations, ..] */
33
+		$translationByDomain = array_reduce($translations, function ($carry, Translations $translations) {
34
+			$carry[$translations->getDomain()] = $translations;
35
+			return $carry;
36
+		}, []);
37
+
38
+		$functions = $options['functions'];
39
+		$file = $options['file'];
40
+
41
+		/**
42
+		 * List of source code comments already associated with a function.
43
+		 *
44
+		 * Prevents associating the same comment to multiple functions.
45
+		 *
46
+		 * @var ParsedComment[] $commentsCache
47
+		 */
48
+		$commentsCache = [];
49
+
50
+		foreach ($this->getFunctions($options['constants']) as $function) {
51
+			list($name, $line, $args) = $function;
52
+
53
+			if (isset($options['lineOffset'])) {
54
+				$line += $options['lineOffset'];
55
+			}
56
+
57
+			if (!isset($functions[$name])) {
58
+				continue;
59
+			}
60
+
61
+			$deconstructed = $this->deconstructArgs($functions[$name], $args);
62
+
63
+			if (!$deconstructed) {
64
+				continue;
65
+			}
66
+
67
+			list($domain, $context, $original, $plural) = $deconstructed;
68
+
69
+			if ((string)$original === '') {
70
+				continue;
71
+			}
72
+
73
+			$isDefaultDomain = $domain === null;
74
+
75
+			$domainTranslations = isset($translationByDomain[$domain]) ? $translationByDomain[$domain] : false;
76
+
77
+			if (!empty($options['domainOnly']) && $isDefaultDomain) {
78
+				// If we want to find translations for a specific domain, skip default domain messages
79
+				continue;
80
+			}
81
+
82
+			if (!$domainTranslations) {
83
+				continue;
84
+			}
85
+
86
+			$translation = $domainTranslations->insert($context, $original, $plural);
87
+			$translation->addReference($file, $line);
88
+
89
+			if (isset($function[3])) {
90
+				/* @var ParsedComment $extractedComment */
91
+				foreach ($function[3] as $extractedComment) {
92
+					if (in_array($extractedComment, $commentsCache, true)) {
93
+						continue;
94
+					}
95
+					$translation->addExtractedComment($extractedComment->getComment());
96
+					$commentsCache[] = $extractedComment;
97
+				}
98
+			}
99
+		}
100
+	}
101
+
102
+	/**
103
+	 * Deconstruct arguments to translation values
104
+	 *
105
+	 * @param $function
106
+	 * @param $args
107
+	 * @return array|null
108
+	 * @throws Exception
109
+	 */
110
+	protected function deconstructArgs($function, $args)
111
+	{
112
+		$domain = null;
113
+		$context = null;
114
+		$original = null;
115
+		$plural = null;
116
+
117
+		switch ($function) {
118
+			case 'noop':
119
+			case 'gettext':
120
+				if (!isset($args[0])) {
121
+					return null;
122
+				}
123
+
124
+				$original = $args[0];
125
+				break;
126
+			case 'ngettext':
127
+				if (!isset($args[1])) {
128
+					return null;
129
+				}
130
+
131
+				list($original, $plural) = $args;
132
+				break;
133
+			case 'pgettext':
134
+				if (!isset($args[1])) {
135
+					return null;
136
+				}
137
+
138
+				list($context, $original) = $args;
139
+				break;
140
+			case 'dgettext':
141
+				if (!isset($args[1])) {
142
+					return null;
143
+				}
144
+
145
+				list($domain, $original) = $args;
146
+				break;
147
+			case 'dpgettext':
148
+				if (!isset($args[2])) {
149
+					return null;
150
+				}
151
+
152
+				list($domain, $context, $original) = $args;
153
+				break;
154
+			case 'npgettext':
155
+				if (!isset($args[2])) {
156
+					return null;
157
+				}
158
+
159
+				list($context, $original, $plural) = $args;
160
+				break;
161
+			case 'dnpgettext':
162
+				if (!isset($args[3])) {
163
+					return null;
164
+				}
165
+
166
+				list($domain, $context, $original, $plural) = $args;
167
+				break;
168
+			case 'dngettext':
169
+				if (!isset($args[2])) {
170
+					return null;
171
+				}
172
+
173
+				list($domain, $original, $plural) = $args;
174
+				break;
175
+			default:
176
+				throw new Exception(sprintf('Not valid function %s', $function));
177
+		}
178
+
179
+		return [$domain, $context, $original, $plural];
180
+	}
181 181
 }
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
      *
15 15
      * @return array
16 16
      */
17
-    abstract public function getFunctions(array $constants = []);
17
+    abstract public function getFunctions( array $constants = [ ] );
18 18
 
19 19
     /**
20 20
      * Search for specific functions and create translations.
@@ -25,18 +25,18 @@  discard block
 block discarded – undo
25 25
      * @param array $options The extractor options
26 26
      * @throws Exception
27 27
      */
28
-    public function saveGettextFunctions($translations, array $options)
28
+    public function saveGettextFunctions( $translations, array $options )
29 29
     {
30
-        $translations = is_array($translations) ? $translations : [$translations];
30
+        $translations = is_array( $translations ) ? $translations : [ $translations ];
31 31
 
32 32
         /** @var Translations[] $translationByDomain [domain => translations, ..] */
33
-        $translationByDomain = array_reduce($translations, function ($carry, Translations $translations) {
34
-            $carry[$translations->getDomain()] = $translations;
33
+        $translationByDomain = array_reduce( $translations, function( $carry, Translations $translations ) {
34
+            $carry[ $translations->getDomain() ] = $translations;
35 35
             return $carry;
36
-        }, []);
36
+        }, [ ] );
37 37
 
38
-        $functions = $options['functions'];
39
-        $file = $options['file'];
38
+        $functions = $options[ 'functions' ];
39
+        $file = $options[ 'file' ];
40 40
 
41 41
         /**
42 42
          * List of source code comments already associated with a function.
@@ -45,55 +45,55 @@  discard block
 block discarded – undo
45 45
          *
46 46
          * @var ParsedComment[] $commentsCache
47 47
          */
48
-        $commentsCache = [];
48
+        $commentsCache = [ ];
49 49
 
50
-        foreach ($this->getFunctions($options['constants']) as $function) {
51
-            list($name, $line, $args) = $function;
50
+        foreach ( $this->getFunctions( $options[ 'constants' ] ) as $function ) {
51
+            list( $name, $line, $args ) = $function;
52 52
 
53
-            if (isset($options['lineOffset'])) {
54
-                $line += $options['lineOffset'];
53
+            if ( isset( $options[ 'lineOffset' ] ) ) {
54
+                $line += $options[ 'lineOffset' ];
55 55
             }
56 56
 
57
-            if (!isset($functions[$name])) {
57
+            if ( ! isset( $functions[ $name ] ) ) {
58 58
                 continue;
59 59
             }
60 60
 
61
-            $deconstructed = $this->deconstructArgs($functions[$name], $args);
61
+            $deconstructed = $this->deconstructArgs( $functions[ $name ], $args );
62 62
 
63
-            if (!$deconstructed) {
63
+            if ( ! $deconstructed ) {
64 64
                 continue;
65 65
             }
66 66
 
67
-            list($domain, $context, $original, $plural) = $deconstructed;
67
+            list( $domain, $context, $original, $plural ) = $deconstructed;
68 68
 
69
-            if ((string)$original === '') {
69
+            if ( (string)$original === '' ) {
70 70
                 continue;
71 71
             }
72 72
 
73 73
             $isDefaultDomain = $domain === null;
74 74
 
75
-            $domainTranslations = isset($translationByDomain[$domain]) ? $translationByDomain[$domain] : false;
75
+            $domainTranslations = isset( $translationByDomain[ $domain ] ) ? $translationByDomain[ $domain ] : false;
76 76
 
77
-            if (!empty($options['domainOnly']) && $isDefaultDomain) {
77
+            if ( ! empty( $options[ 'domainOnly' ] ) && $isDefaultDomain ) {
78 78
                 // If we want to find translations for a specific domain, skip default domain messages
79 79
                 continue;
80 80
             }
81 81
 
82
-            if (!$domainTranslations) {
82
+            if ( ! $domainTranslations ) {
83 83
                 continue;
84 84
             }
85 85
 
86
-            $translation = $domainTranslations->insert($context, $original, $plural);
87
-            $translation->addReference($file, $line);
86
+            $translation = $domainTranslations->insert( $context, $original, $plural );
87
+            $translation->addReference( $file, $line );
88 88
 
89
-            if (isset($function[3])) {
89
+            if ( isset( $function[ 3 ] ) ) {
90 90
                 /* @var ParsedComment $extractedComment */
91
-                foreach ($function[3] as $extractedComment) {
92
-                    if (in_array($extractedComment, $commentsCache, true)) {
91
+                foreach ( $function[ 3 ] as $extractedComment ) {
92
+                    if ( in_array( $extractedComment, $commentsCache, true ) ) {
93 93
                         continue;
94 94
                     }
95
-                    $translation->addExtractedComment($extractedComment->getComment());
96
-                    $commentsCache[] = $extractedComment;
95
+                    $translation->addExtractedComment( $extractedComment->getComment() );
96
+                    $commentsCache[ ] = $extractedComment;
97 97
                 }
98 98
             }
99 99
         }
@@ -107,75 +107,75 @@  discard block
 block discarded – undo
107 107
      * @return array|null
108 108
      * @throws Exception
109 109
      */
110
-    protected function deconstructArgs($function, $args)
110
+    protected function deconstructArgs( $function, $args )
111 111
     {
112 112
         $domain = null;
113 113
         $context = null;
114 114
         $original = null;
115 115
         $plural = null;
116 116
 
117
-        switch ($function) {
117
+        switch ( $function ) {
118 118
             case 'noop':
119 119
             case 'gettext':
120
-                if (!isset($args[0])) {
120
+                if ( ! isset( $args[ 0 ] ) ) {
121 121
                     return null;
122 122
                 }
123 123
 
124
-                $original = $args[0];
124
+                $original = $args[ 0 ];
125 125
                 break;
126 126
             case 'ngettext':
127
-                if (!isset($args[1])) {
127
+                if ( ! isset( $args[ 1 ] ) ) {
128 128
                     return null;
129 129
                 }
130 130
 
131
-                list($original, $plural) = $args;
131
+                list( $original, $plural ) = $args;
132 132
                 break;
133 133
             case 'pgettext':
134
-                if (!isset($args[1])) {
134
+                if ( ! isset( $args[ 1 ] ) ) {
135 135
                     return null;
136 136
                 }
137 137
 
138
-                list($context, $original) = $args;
138
+                list( $context, $original ) = $args;
139 139
                 break;
140 140
             case 'dgettext':
141
-                if (!isset($args[1])) {
141
+                if ( ! isset( $args[ 1 ] ) ) {
142 142
                     return null;
143 143
                 }
144 144
 
145
-                list($domain, $original) = $args;
145
+                list( $domain, $original ) = $args;
146 146
                 break;
147 147
             case 'dpgettext':
148
-                if (!isset($args[2])) {
148
+                if ( ! isset( $args[ 2 ] ) ) {
149 149
                     return null;
150 150
                 }
151 151
 
152
-                list($domain, $context, $original) = $args;
152
+                list( $domain, $context, $original ) = $args;
153 153
                 break;
154 154
             case 'npgettext':
155
-                if (!isset($args[2])) {
155
+                if ( ! isset( $args[ 2 ] ) ) {
156 156
                     return null;
157 157
                 }
158 158
 
159
-                list($context, $original, $plural) = $args;
159
+                list( $context, $original, $plural ) = $args;
160 160
                 break;
161 161
             case 'dnpgettext':
162
-                if (!isset($args[3])) {
162
+                if ( ! isset( $args[ 3 ] ) ) {
163 163
                     return null;
164 164
                 }
165 165
 
166
-                list($domain, $context, $original, $plural) = $args;
166
+                list( $domain, $context, $original, $plural ) = $args;
167 167
                 break;
168 168
             case 'dngettext':
169
-                if (!isset($args[2])) {
169
+                if ( ! isset( $args[ 2 ] ) ) {
170 170
                     return null;
171 171
                 }
172 172
 
173
-                list($domain, $original, $plural) = $args;
173
+                list( $domain, $original, $plural ) = $args;
174 174
                 break;
175 175
             default:
176
-                throw new Exception(sprintf('Not valid function %s', $function));
176
+                throw new Exception( sprintf( 'Not valid function %s', $function ) );
177 177
         }
178 178
 
179
-        return [$domain, $context, $original, $plural];
179
+        return [ $domain, $context, $original, $plural ];
180 180
     }
181 181
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -5,8 +5,7 @@  discard block
 block discarded – undo
5 5
 use Exception;
6 6
 use Gettext\Translations;
7 7
 
8
-abstract class FunctionsScanner
9
-{
8
+abstract class FunctionsScanner {
10 9
     /**
11 10
      * Scan and returns the functions and the arguments.
12 11
      *
@@ -25,8 +24,7 @@  discard block
 block discarded – undo
25 24
      * @param array $options The extractor options
26 25
      * @throws Exception
27 26
      */
28
-    public function saveGettextFunctions($translations, array $options)
29
-    {
27
+    public function saveGettextFunctions($translations, array $options) {
30 28
         $translations = is_array($translations) ? $translations : [$translations];
31 29
 
32 30
         /** @var Translations[] $translationByDomain [domain => translations, ..] */
@@ -107,8 +105,7 @@  discard block
 block discarded – undo
107 105
      * @return array|null
108 106
      * @throws Exception
109 107
      */
110
-    protected function deconstructArgs($function, $args)
111
-    {
108
+    protected function deconstructArgs($function, $args) {
112 109
         $domain = null;
113 110
         $context = null;
114 111
         $original = null;
Please login to merge, or discard this patch.
vendor/gettext/gettext/src/Utils/MultidimensionalArrayTrait.php 3 patches
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -10,91 +10,91 @@
 block discarded – undo
10 10
  */
11 11
 trait MultidimensionalArrayTrait
12 12
 {
13
-    use HeadersGeneratorTrait;
14
-    use HeadersExtractorTrait;
13
+	use HeadersGeneratorTrait;
14
+	use HeadersExtractorTrait;
15 15
 
16
-    /**
17
-     * Returns a multidimensional array.
18
-     *
19
-     * @param Translations $translations
20
-     * @param bool         $includeHeaders
21
-     * @param bool         $forceArray
22
-     *
23
-     * @return array
24
-     */
25
-    protected static function toArray(Translations $translations, $includeHeaders, $forceArray = false)
26
-    {
27
-        $pluralForm = $translations->getPluralForms();
28
-        $pluralSize = is_array($pluralForm) ? ($pluralForm[0] - 1) : null;
29
-        $messages = [];
16
+	/**
17
+	 * Returns a multidimensional array.
18
+	 *
19
+	 * @param Translations $translations
20
+	 * @param bool         $includeHeaders
21
+	 * @param bool         $forceArray
22
+	 *
23
+	 * @return array
24
+	 */
25
+	protected static function toArray(Translations $translations, $includeHeaders, $forceArray = false)
26
+	{
27
+		$pluralForm = $translations->getPluralForms();
28
+		$pluralSize = is_array($pluralForm) ? ($pluralForm[0] - 1) : null;
29
+		$messages = [];
30 30
 
31
-        if ($includeHeaders) {
32
-            $messages[''] = [
33
-                '' => [static::generateHeaders($translations)],
34
-            ];
35
-        }
31
+		if ($includeHeaders) {
32
+			$messages[''] = [
33
+				'' => [static::generateHeaders($translations)],
34
+			];
35
+		}
36 36
 
37
-        foreach ($translations as $translation) {
38
-            if ($translation->isDisabled()) {
39
-                continue;
40
-            }
37
+		foreach ($translations as $translation) {
38
+			if ($translation->isDisabled()) {
39
+				continue;
40
+			}
41 41
 
42
-            $context = $translation->getContext();
43
-            $original = $translation->getOriginal();
42
+			$context = $translation->getContext();
43
+			$original = $translation->getOriginal();
44 44
 
45
-            if (!isset($messages[$context])) {
46
-                $messages[$context] = [];
47
-            }
45
+			if (!isset($messages[$context])) {
46
+				$messages[$context] = [];
47
+			}
48 48
 
49
-            if ($translation->hasPluralTranslations(true)) {
50
-                $messages[$context][$original] = $translation->getPluralTranslations($pluralSize);
51
-                array_unshift($messages[$context][$original], $translation->getTranslation());
52
-            } elseif ($forceArray) {
53
-                $messages[$context][$original] = [$translation->getTranslation()];
54
-            } else {
55
-                $messages[$context][$original] = $translation->getTranslation();
56
-            }
57
-        }
49
+			if ($translation->hasPluralTranslations(true)) {
50
+				$messages[$context][$original] = $translation->getPluralTranslations($pluralSize);
51
+				array_unshift($messages[$context][$original], $translation->getTranslation());
52
+			} elseif ($forceArray) {
53
+				$messages[$context][$original] = [$translation->getTranslation()];
54
+			} else {
55
+				$messages[$context][$original] = $translation->getTranslation();
56
+			}
57
+		}
58 58
 
59
-        return [
60
-            'domain' => $translations->getDomain(),
61
-            'plural-forms' => $translations->getHeader('Plural-Forms'),
62
-            'messages' => $messages,
63
-        ];
64
-    }
59
+		return [
60
+			'domain' => $translations->getDomain(),
61
+			'plural-forms' => $translations->getHeader('Plural-Forms'),
62
+			'messages' => $messages,
63
+		];
64
+	}
65 65
 
66
-    /**
67
-     * Extract the entries from a multidimensional array.
68
-     *
69
-     * @param array        $messages
70
-     * @param Translations $translations
71
-     */
72
-    protected static function fromArray(array $messages, Translations $translations)
73
-    {
74
-        if (!empty($messages['domain'])) {
75
-            $translations->setDomain($messages['domain']);
76
-        }
66
+	/**
67
+	 * Extract the entries from a multidimensional array.
68
+	 *
69
+	 * @param array        $messages
70
+	 * @param Translations $translations
71
+	 */
72
+	protected static function fromArray(array $messages, Translations $translations)
73
+	{
74
+		if (!empty($messages['domain'])) {
75
+			$translations->setDomain($messages['domain']);
76
+		}
77 77
 
78
-        if (!empty($messages['plural-forms'])) {
79
-            $translations->setHeader(Translations::HEADER_PLURAL, $messages['plural-forms']);
80
-        }
78
+		if (!empty($messages['plural-forms'])) {
79
+			$translations->setHeader(Translations::HEADER_PLURAL, $messages['plural-forms']);
80
+		}
81 81
 
82
-        foreach ($messages['messages'] as $context => $contextTranslations) {
83
-            foreach ($contextTranslations as $original => $value) {
84
-                if ($context === '' && $original === '') {
85
-                    static::extractHeaders(is_array($value) ? array_shift($value) : $value, $translations);
86
-                    continue;
87
-                }
82
+		foreach ($messages['messages'] as $context => $contextTranslations) {
83
+			foreach ($contextTranslations as $original => $value) {
84
+				if ($context === '' && $original === '') {
85
+					static::extractHeaders(is_array($value) ? array_shift($value) : $value, $translations);
86
+					continue;
87
+				}
88 88
 
89
-                $translation = $translations->insert($context, $original);
89
+				$translation = $translations->insert($context, $original);
90 90
 
91
-                if (is_array($value)) {
92
-                    $translation->setTranslation(array_shift($value));
93
-                    $translation->setPluralTranslations($value);
94
-                } else {
95
-                    $translation->setTranslation($value);
96
-                }
97
-            }
98
-        }
99
-    }
91
+				if (is_array($value)) {
92
+					$translation->setTranslation(array_shift($value));
93
+					$translation->setPluralTranslations($value);
94
+				} else {
95
+					$translation->setTranslation($value);
96
+				}
97
+			}
98
+		}
99
+	}
100 100
 }
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -22,43 +22,43 @@  discard block
 block discarded – undo
22 22
      *
23 23
      * @return array
24 24
      */
25
-    protected static function toArray(Translations $translations, $includeHeaders, $forceArray = false)
25
+    protected static function toArray( Translations $translations, $includeHeaders, $forceArray = false )
26 26
     {
27 27
         $pluralForm = $translations->getPluralForms();
28
-        $pluralSize = is_array($pluralForm) ? ($pluralForm[0] - 1) : null;
29
-        $messages = [];
28
+        $pluralSize = is_array( $pluralForm ) ? ( $pluralForm[ 0 ] - 1 ) : null;
29
+        $messages = [ ];
30 30
 
31
-        if ($includeHeaders) {
32
-            $messages[''] = [
33
-                '' => [static::generateHeaders($translations)],
31
+        if ( $includeHeaders ) {
32
+            $messages[ '' ] = [
33
+                '' => [ static::generateHeaders( $translations ) ],
34 34
             ];
35 35
         }
36 36
 
37
-        foreach ($translations as $translation) {
38
-            if ($translation->isDisabled()) {
37
+        foreach ( $translations as $translation ) {
38
+            if ( $translation->isDisabled() ) {
39 39
                 continue;
40 40
             }
41 41
 
42 42
             $context = $translation->getContext();
43 43
             $original = $translation->getOriginal();
44 44
 
45
-            if (!isset($messages[$context])) {
46
-                $messages[$context] = [];
45
+            if ( ! isset( $messages[ $context ] ) ) {
46
+                $messages[ $context ] = [ ];
47 47
             }
48 48
 
49
-            if ($translation->hasPluralTranslations(true)) {
50
-                $messages[$context][$original] = $translation->getPluralTranslations($pluralSize);
51
-                array_unshift($messages[$context][$original], $translation->getTranslation());
52
-            } elseif ($forceArray) {
53
-                $messages[$context][$original] = [$translation->getTranslation()];
49
+            if ( $translation->hasPluralTranslations( true ) ) {
50
+                $messages[ $context ][ $original ] = $translation->getPluralTranslations( $pluralSize );
51
+                array_unshift( $messages[ $context ][ $original ], $translation->getTranslation() );
52
+            } elseif ( $forceArray ) {
53
+                $messages[ $context ][ $original ] = [ $translation->getTranslation() ];
54 54
             } else {
55
-                $messages[$context][$original] = $translation->getTranslation();
55
+                $messages[ $context ][ $original ] = $translation->getTranslation();
56 56
             }
57 57
         }
58 58
 
59 59
         return [
60 60
             'domain' => $translations->getDomain(),
61
-            'plural-forms' => $translations->getHeader('Plural-Forms'),
61
+            'plural-forms' => $translations->getHeader( 'Plural-Forms' ),
62 62
             'messages' => $messages,
63 63
         ];
64 64
     }
@@ -69,30 +69,30 @@  discard block
 block discarded – undo
69 69
      * @param array        $messages
70 70
      * @param Translations $translations
71 71
      */
72
-    protected static function fromArray(array $messages, Translations $translations)
72
+    protected static function fromArray( array $messages, Translations $translations )
73 73
     {
74
-        if (!empty($messages['domain'])) {
75
-            $translations->setDomain($messages['domain']);
74
+        if ( ! empty( $messages[ 'domain' ] ) ) {
75
+            $translations->setDomain( $messages[ 'domain' ] );
76 76
         }
77 77
 
78
-        if (!empty($messages['plural-forms'])) {
79
-            $translations->setHeader(Translations::HEADER_PLURAL, $messages['plural-forms']);
78
+        if ( ! empty( $messages[ 'plural-forms' ] ) ) {
79
+            $translations->setHeader( Translations::HEADER_PLURAL, $messages[ 'plural-forms' ] );
80 80
         }
81 81
 
82
-        foreach ($messages['messages'] as $context => $contextTranslations) {
83
-            foreach ($contextTranslations as $original => $value) {
84
-                if ($context === '' && $original === '') {
85
-                    static::extractHeaders(is_array($value) ? array_shift($value) : $value, $translations);
82
+        foreach ( $messages[ 'messages' ] as $context => $contextTranslations ) {
83
+            foreach ( $contextTranslations as $original => $value ) {
84
+                if ( $context === '' && $original === '' ) {
85
+                    static::extractHeaders( is_array( $value ) ? array_shift( $value ) : $value, $translations );
86 86
                     continue;
87 87
                 }
88 88
 
89
-                $translation = $translations->insert($context, $original);
89
+                $translation = $translations->insert( $context, $original );
90 90
 
91
-                if (is_array($value)) {
92
-                    $translation->setTranslation(array_shift($value));
93
-                    $translation->setPluralTranslations($value);
91
+                if ( is_array( $value ) ) {
92
+                    $translation->setTranslation( array_shift( $value ) );
93
+                    $translation->setPluralTranslations( $value );
94 94
                 } else {
95
-                    $translation->setTranslation($value);
95
+                    $translation->setTranslation( $value );
96 96
                 }
97 97
             }
98 98
         }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -8,8 +8,7 @@  discard block
 block discarded – undo
8 8
  * Trait used by all generators that exports the translations to multidimensional arrays
9 9
  * (context => [original => [translation, plural1, pluraln...]]).
10 10
  */
11
-trait MultidimensionalArrayTrait
12
-{
11
+trait MultidimensionalArrayTrait {
13 12
     use HeadersGeneratorTrait;
14 13
     use HeadersExtractorTrait;
15 14
 
@@ -22,8 +21,7 @@  discard block
 block discarded – undo
22 21
      *
23 22
      * @return array
24 23
      */
25
-    protected static function toArray(Translations $translations, $includeHeaders, $forceArray = false)
26
-    {
24
+    protected static function toArray(Translations $translations, $includeHeaders, $forceArray = false) {
27 25
         $pluralForm = $translations->getPluralForms();
28 26
         $pluralSize = is_array($pluralForm) ? ($pluralForm[0] - 1) : null;
29 27
         $messages = [];
@@ -69,8 +67,7 @@  discard block
 block discarded – undo
69 67
      * @param array        $messages
70 68
      * @param Translations $translations
71 69
      */
72
-    protected static function fromArray(array $messages, Translations $translations)
73
-    {
70
+    protected static function fromArray(array $messages, Translations $translations) {
74 71
         if (!empty($messages['domain'])) {
75 72
             $translations->setDomain($messages['domain']);
76 73
         }
Please login to merge, or discard this patch.
vendor/gettext/gettext/src/Merge.php 3 patches
Indentation   +211 added lines, -211 removed lines patch added patch discarded remove patch
@@ -7,215 +7,215 @@
 block discarded – undo
7 7
  */
8 8
 final class Merge
9 9
 {
10
-    const ADD = 1;
11
-    const REMOVE = 2;
12
-
13
-    const HEADERS_ADD = 4;
14
-    const HEADERS_REMOVE = 8;
15
-    const HEADERS_OVERRIDE = 16;
16
-
17
-    const LANGUAGE_OVERRIDE = 32;
18
-    const DOMAIN_OVERRIDE = 64;
19
-    const TRANSLATION_OVERRIDE = 128;
20
-
21
-    const COMMENTS_OURS = 256;
22
-    const COMMENTS_THEIRS = 512;
23
-
24
-    const EXTRACTED_COMMENTS_OURS = 1024;
25
-    const EXTRACTED_COMMENTS_THEIRS = 2048;
26
-
27
-    const FLAGS_OURS = 4096;
28
-    const FLAGS_THEIRS = 8192;
29
-
30
-    const REFERENCES_OURS = 16384;
31
-    const REFERENCES_THEIRS = 32768;
32
-
33
-    const DEFAULTS = 5; //1 + 4
34
-
35
-    /**
36
-     * Merge the flags of two translations.
37
-     *
38
-     * @param Translation $from
39
-     * @param Translation $to
40
-     * @param int         $options
41
-     */
42
-    public static function mergeFlags(Translation $from, Translation $to, $options = self::DEFAULTS)
43
-    {
44
-        if ($options & self::FLAGS_THEIRS) {
45
-            $to->deleteFlags();
46
-        }
47
-
48
-        if (!($options & self::FLAGS_OURS)) {
49
-            foreach ($from->getFlags() as $flag) {
50
-                $to->addFlag($flag);
51
-            }
52
-        }
53
-    }
54
-
55
-    /**
56
-     * Merge the extracted comments of two translations.
57
-     *
58
-     * @param Translation $from
59
-     * @param Translation $to
60
-     * @param int         $options
61
-     */
62
-    public static function mergeExtractedComments(Translation $from, Translation $to, $options = self::DEFAULTS)
63
-    {
64
-        if ($options & self::EXTRACTED_COMMENTS_THEIRS) {
65
-            $to->deleteExtractedComments();
66
-        }
67
-
68
-        if (!($options & self::EXTRACTED_COMMENTS_OURS)) {
69
-            foreach ($from->getExtractedComments() as $comment) {
70
-                $to->addExtractedComment($comment);
71
-            }
72
-        }
73
-    }
74
-
75
-    /**
76
-     * Merge the comments of two translations.
77
-     *
78
-     * @param Translation $from
79
-     * @param Translation $to
80
-     * @param int         $options
81
-     */
82
-    public static function mergeComments(Translation $from, Translation $to, $options = self::DEFAULTS)
83
-    {
84
-        if ($options & self::COMMENTS_THEIRS) {
85
-            $to->deleteComments();
86
-        }
87
-
88
-        if (!($options & self::COMMENTS_OURS)) {
89
-            foreach ($from->getComments() as $comment) {
90
-                $to->addComment($comment);
91
-            }
92
-        }
93
-    }
94
-
95
-    /**
96
-     * Merge the references of two translations.
97
-     *
98
-     * @param Translation $from
99
-     * @param Translation $to
100
-     * @param int         $options
101
-     */
102
-    public static function mergeReferences(Translation $from, Translation $to, $options = self::DEFAULTS)
103
-    {
104
-        if ($options & self::REFERENCES_THEIRS) {
105
-            $to->deleteReferences();
106
-        }
107
-
108
-        if (!($options & self::REFERENCES_OURS)) {
109
-            foreach ($from->getReferences() as $reference) {
110
-                $to->addReference($reference[0], $reference[1]);
111
-            }
112
-        }
113
-    }
114
-
115
-    /**
116
-     * Merge the translations of two translations.
117
-     *
118
-     * @param Translation $from
119
-     * @param Translation $to
120
-     * @param int         $options
121
-     */
122
-    public static function mergeTranslation(Translation $from, Translation $to, $options = self::DEFAULTS)
123
-    {
124
-        $override = (boolean) ($options & self::TRANSLATION_OVERRIDE);
125
-
126
-        if (!$to->hasTranslation() || ($from->hasTranslation() && $override)) {
127
-            $to->setTranslation($from->getTranslation());
128
-        }
129
-
130
-        if (!$to->hasPlural() || ($from->hasPlural() && $override)) {
131
-            $to->setPlural($from->getPlural());
132
-        }
133
-
134
-        if (!$to->hasPluralTranslations() || ($from->hasPluralTranslations() && $override)) {
135
-            $to->setPluralTranslations($from->getPluralTranslations());
136
-        }
137
-    }
138
-
139
-    /**
140
-     * Merge the translations of two translations.
141
-     *
142
-     * @param Translations $from
143
-     * @param Translations $to
144
-     * @param int          $options
145
-     */
146
-    public static function mergeTranslations(Translations $from, Translations $to, $options = self::DEFAULTS)
147
-    {
148
-        if ($options & self::REMOVE) {
149
-            $filtered = [];
150
-
151
-            foreach ($to as $entry) {
152
-                if ($from->find($entry)) {
153
-                    $filtered[$entry->getId()] = $entry;
154
-                }
155
-            }
156
-
157
-            $to->exchangeArray($filtered);
158
-        }
159
-
160
-        foreach ($from as $entry) {
161
-            if (($existing = $to->find($entry))) {
162
-                $existing->mergeWith($entry, $options);
163
-            } elseif ($options & self::ADD) {
164
-                $to[] = $entry->getClone();
165
-            }
166
-        }
167
-    }
168
-
169
-    /**
170
-     * Merge the headers of two translations.
171
-     *
172
-     * @param Translations $from
173
-     * @param Translations $to
174
-     * @param int          $options
175
-     */
176
-    public static function mergeHeaders(Translations $from, Translations $to, $options = self::DEFAULTS)
177
-    {
178
-        if ($options & self::HEADERS_REMOVE) {
179
-            foreach (array_keys($to->getHeaders()) as $name) {
180
-                if ($from->getHeader($name) === null) {
181
-                    $to->deleteHeader($name);
182
-                }
183
-            }
184
-        }
185
-
186
-        foreach ($from->getHeaders() as $name => $value) {
187
-            $current = $to->getHeader($name);
188
-
189
-            if (empty($current)) {
190
-                if ($options & self::HEADERS_ADD) {
191
-                    $to->setHeader($name, $value);
192
-                }
193
-                continue;
194
-            }
195
-
196
-            if (empty($value)) {
197
-                continue;
198
-            }
199
-
200
-            switch ($name) {
201
-                case Translations::HEADER_LANGUAGE:
202
-                case Translations::HEADER_PLURAL:
203
-                    if ($options & self::LANGUAGE_OVERRIDE) {
204
-                        $to->setHeader($name, $value);
205
-                    }
206
-                    break;
207
-
208
-                case Translations::HEADER_DOMAIN:
209
-                    if ($options & self::DOMAIN_OVERRIDE) {
210
-                        $to->setHeader($name, $value);
211
-                    }
212
-                    break;
213
-
214
-                default:
215
-                    if ($options & self::HEADERS_OVERRIDE) {
216
-                        $to->setHeader($name, $value);
217
-                    }
218
-            }
219
-        }
220
-    }
10
+	const ADD = 1;
11
+	const REMOVE = 2;
12
+
13
+	const HEADERS_ADD = 4;
14
+	const HEADERS_REMOVE = 8;
15
+	const HEADERS_OVERRIDE = 16;
16
+
17
+	const LANGUAGE_OVERRIDE = 32;
18
+	const DOMAIN_OVERRIDE = 64;
19
+	const TRANSLATION_OVERRIDE = 128;
20
+
21
+	const COMMENTS_OURS = 256;
22
+	const COMMENTS_THEIRS = 512;
23
+
24
+	const EXTRACTED_COMMENTS_OURS = 1024;
25
+	const EXTRACTED_COMMENTS_THEIRS = 2048;
26
+
27
+	const FLAGS_OURS = 4096;
28
+	const FLAGS_THEIRS = 8192;
29
+
30
+	const REFERENCES_OURS = 16384;
31
+	const REFERENCES_THEIRS = 32768;
32
+
33
+	const DEFAULTS = 5; //1 + 4
34
+
35
+	/**
36
+	 * Merge the flags of two translations.
37
+	 *
38
+	 * @param Translation $from
39
+	 * @param Translation $to
40
+	 * @param int         $options
41
+	 */
42
+	public static function mergeFlags(Translation $from, Translation $to, $options = self::DEFAULTS)
43
+	{
44
+		if ($options & self::FLAGS_THEIRS) {
45
+			$to->deleteFlags();
46
+		}
47
+
48
+		if (!($options & self::FLAGS_OURS)) {
49
+			foreach ($from->getFlags() as $flag) {
50
+				$to->addFlag($flag);
51
+			}
52
+		}
53
+	}
54
+
55
+	/**
56
+	 * Merge the extracted comments of two translations.
57
+	 *
58
+	 * @param Translation $from
59
+	 * @param Translation $to
60
+	 * @param int         $options
61
+	 */
62
+	public static function mergeExtractedComments(Translation $from, Translation $to, $options = self::DEFAULTS)
63
+	{
64
+		if ($options & self::EXTRACTED_COMMENTS_THEIRS) {
65
+			$to->deleteExtractedComments();
66
+		}
67
+
68
+		if (!($options & self::EXTRACTED_COMMENTS_OURS)) {
69
+			foreach ($from->getExtractedComments() as $comment) {
70
+				$to->addExtractedComment($comment);
71
+			}
72
+		}
73
+	}
74
+
75
+	/**
76
+	 * Merge the comments of two translations.
77
+	 *
78
+	 * @param Translation $from
79
+	 * @param Translation $to
80
+	 * @param int         $options
81
+	 */
82
+	public static function mergeComments(Translation $from, Translation $to, $options = self::DEFAULTS)
83
+	{
84
+		if ($options & self::COMMENTS_THEIRS) {
85
+			$to->deleteComments();
86
+		}
87
+
88
+		if (!($options & self::COMMENTS_OURS)) {
89
+			foreach ($from->getComments() as $comment) {
90
+				$to->addComment($comment);
91
+			}
92
+		}
93
+	}
94
+
95
+	/**
96
+	 * Merge the references of two translations.
97
+	 *
98
+	 * @param Translation $from
99
+	 * @param Translation $to
100
+	 * @param int         $options
101
+	 */
102
+	public static function mergeReferences(Translation $from, Translation $to, $options = self::DEFAULTS)
103
+	{
104
+		if ($options & self::REFERENCES_THEIRS) {
105
+			$to->deleteReferences();
106
+		}
107
+
108
+		if (!($options & self::REFERENCES_OURS)) {
109
+			foreach ($from->getReferences() as $reference) {
110
+				$to->addReference($reference[0], $reference[1]);
111
+			}
112
+		}
113
+	}
114
+
115
+	/**
116
+	 * Merge the translations of two translations.
117
+	 *
118
+	 * @param Translation $from
119
+	 * @param Translation $to
120
+	 * @param int         $options
121
+	 */
122
+	public static function mergeTranslation(Translation $from, Translation $to, $options = self::DEFAULTS)
123
+	{
124
+		$override = (boolean) ($options & self::TRANSLATION_OVERRIDE);
125
+
126
+		if (!$to->hasTranslation() || ($from->hasTranslation() && $override)) {
127
+			$to->setTranslation($from->getTranslation());
128
+		}
129
+
130
+		if (!$to->hasPlural() || ($from->hasPlural() && $override)) {
131
+			$to->setPlural($from->getPlural());
132
+		}
133
+
134
+		if (!$to->hasPluralTranslations() || ($from->hasPluralTranslations() && $override)) {
135
+			$to->setPluralTranslations($from->getPluralTranslations());
136
+		}
137
+	}
138
+
139
+	/**
140
+	 * Merge the translations of two translations.
141
+	 *
142
+	 * @param Translations $from
143
+	 * @param Translations $to
144
+	 * @param int          $options
145
+	 */
146
+	public static function mergeTranslations(Translations $from, Translations $to, $options = self::DEFAULTS)
147
+	{
148
+		if ($options & self::REMOVE) {
149
+			$filtered = [];
150
+
151
+			foreach ($to as $entry) {
152
+				if ($from->find($entry)) {
153
+					$filtered[$entry->getId()] = $entry;
154
+				}
155
+			}
156
+
157
+			$to->exchangeArray($filtered);
158
+		}
159
+
160
+		foreach ($from as $entry) {
161
+			if (($existing = $to->find($entry))) {
162
+				$existing->mergeWith($entry, $options);
163
+			} elseif ($options & self::ADD) {
164
+				$to[] = $entry->getClone();
165
+			}
166
+		}
167
+	}
168
+
169
+	/**
170
+	 * Merge the headers of two translations.
171
+	 *
172
+	 * @param Translations $from
173
+	 * @param Translations $to
174
+	 * @param int          $options
175
+	 */
176
+	public static function mergeHeaders(Translations $from, Translations $to, $options = self::DEFAULTS)
177
+	{
178
+		if ($options & self::HEADERS_REMOVE) {
179
+			foreach (array_keys($to->getHeaders()) as $name) {
180
+				if ($from->getHeader($name) === null) {
181
+					$to->deleteHeader($name);
182
+				}
183
+			}
184
+		}
185
+
186
+		foreach ($from->getHeaders() as $name => $value) {
187
+			$current = $to->getHeader($name);
188
+
189
+			if (empty($current)) {
190
+				if ($options & self::HEADERS_ADD) {
191
+					$to->setHeader($name, $value);
192
+				}
193
+				continue;
194
+			}
195
+
196
+			if (empty($value)) {
197
+				continue;
198
+			}
199
+
200
+			switch ($name) {
201
+				case Translations::HEADER_LANGUAGE:
202
+				case Translations::HEADER_PLURAL:
203
+					if ($options & self::LANGUAGE_OVERRIDE) {
204
+						$to->setHeader($name, $value);
205
+					}
206
+					break;
207
+
208
+				case Translations::HEADER_DOMAIN:
209
+					if ($options & self::DOMAIN_OVERRIDE) {
210
+						$to->setHeader($name, $value);
211
+					}
212
+					break;
213
+
214
+				default:
215
+					if ($options & self::HEADERS_OVERRIDE) {
216
+						$to->setHeader($name, $value);
217
+					}
218
+			}
219
+		}
220
+	}
221 221
 }
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -39,15 +39,15 @@  discard block
 block discarded – undo
39 39
      * @param Translation $to
40 40
      * @param int         $options
41 41
      */
42
-    public static function mergeFlags(Translation $from, Translation $to, $options = self::DEFAULTS)
42
+    public static function mergeFlags( Translation $from, Translation $to, $options = self::DEFAULTS )
43 43
     {
44
-        if ($options & self::FLAGS_THEIRS) {
44
+        if ( $options & self::FLAGS_THEIRS ) {
45 45
             $to->deleteFlags();
46 46
         }
47 47
 
48
-        if (!($options & self::FLAGS_OURS)) {
49
-            foreach ($from->getFlags() as $flag) {
50
-                $to->addFlag($flag);
48
+        if ( ! ( $options & self::FLAGS_OURS ) ) {
49
+            foreach ( $from->getFlags() as $flag ) {
50
+                $to->addFlag( $flag );
51 51
             }
52 52
         }
53 53
     }
@@ -59,15 +59,15 @@  discard block
 block discarded – undo
59 59
      * @param Translation $to
60 60
      * @param int         $options
61 61
      */
62
-    public static function mergeExtractedComments(Translation $from, Translation $to, $options = self::DEFAULTS)
62
+    public static function mergeExtractedComments( Translation $from, Translation $to, $options = self::DEFAULTS )
63 63
     {
64
-        if ($options & self::EXTRACTED_COMMENTS_THEIRS) {
64
+        if ( $options & self::EXTRACTED_COMMENTS_THEIRS ) {
65 65
             $to->deleteExtractedComments();
66 66
         }
67 67
 
68
-        if (!($options & self::EXTRACTED_COMMENTS_OURS)) {
69
-            foreach ($from->getExtractedComments() as $comment) {
70
-                $to->addExtractedComment($comment);
68
+        if ( ! ( $options & self::EXTRACTED_COMMENTS_OURS ) ) {
69
+            foreach ( $from->getExtractedComments() as $comment ) {
70
+                $to->addExtractedComment( $comment );
71 71
             }
72 72
         }
73 73
     }
@@ -79,15 +79,15 @@  discard block
 block discarded – undo
79 79
      * @param Translation $to
80 80
      * @param int         $options
81 81
      */
82
-    public static function mergeComments(Translation $from, Translation $to, $options = self::DEFAULTS)
82
+    public static function mergeComments( Translation $from, Translation $to, $options = self::DEFAULTS )
83 83
     {
84
-        if ($options & self::COMMENTS_THEIRS) {
84
+        if ( $options & self::COMMENTS_THEIRS ) {
85 85
             $to->deleteComments();
86 86
         }
87 87
 
88
-        if (!($options & self::COMMENTS_OURS)) {
89
-            foreach ($from->getComments() as $comment) {
90
-                $to->addComment($comment);
88
+        if ( ! ( $options & self::COMMENTS_OURS ) ) {
89
+            foreach ( $from->getComments() as $comment ) {
90
+                $to->addComment( $comment );
91 91
             }
92 92
         }
93 93
     }
@@ -99,15 +99,15 @@  discard block
 block discarded – undo
99 99
      * @param Translation $to
100 100
      * @param int         $options
101 101
      */
102
-    public static function mergeReferences(Translation $from, Translation $to, $options = self::DEFAULTS)
102
+    public static function mergeReferences( Translation $from, Translation $to, $options = self::DEFAULTS )
103 103
     {
104
-        if ($options & self::REFERENCES_THEIRS) {
104
+        if ( $options & self::REFERENCES_THEIRS ) {
105 105
             $to->deleteReferences();
106 106
         }
107 107
 
108
-        if (!($options & self::REFERENCES_OURS)) {
109
-            foreach ($from->getReferences() as $reference) {
110
-                $to->addReference($reference[0], $reference[1]);
108
+        if ( ! ( $options & self::REFERENCES_OURS ) ) {
109
+            foreach ( $from->getReferences() as $reference ) {
110
+                $to->addReference( $reference[ 0 ], $reference[ 1 ] );
111 111
             }
112 112
         }
113 113
     }
@@ -119,20 +119,20 @@  discard block
 block discarded – undo
119 119
      * @param Translation $to
120 120
      * @param int         $options
121 121
      */
122
-    public static function mergeTranslation(Translation $from, Translation $to, $options = self::DEFAULTS)
122
+    public static function mergeTranslation( Translation $from, Translation $to, $options = self::DEFAULTS )
123 123
     {
124
-        $override = (boolean) ($options & self::TRANSLATION_OVERRIDE);
124
+        $override = (boolean)( $options & self::TRANSLATION_OVERRIDE );
125 125
 
126
-        if (!$to->hasTranslation() || ($from->hasTranslation() && $override)) {
127
-            $to->setTranslation($from->getTranslation());
126
+        if ( ! $to->hasTranslation() || ( $from->hasTranslation() && $override ) ) {
127
+            $to->setTranslation( $from->getTranslation() );
128 128
         }
129 129
 
130
-        if (!$to->hasPlural() || ($from->hasPlural() && $override)) {
131
-            $to->setPlural($from->getPlural());
130
+        if ( ! $to->hasPlural() || ( $from->hasPlural() && $override ) ) {
131
+            $to->setPlural( $from->getPlural() );
132 132
         }
133 133
 
134
-        if (!$to->hasPluralTranslations() || ($from->hasPluralTranslations() && $override)) {
135
-            $to->setPluralTranslations($from->getPluralTranslations());
134
+        if ( ! $to->hasPluralTranslations() || ( $from->hasPluralTranslations() && $override ) ) {
135
+            $to->setPluralTranslations( $from->getPluralTranslations() );
136 136
         }
137 137
     }
138 138
 
@@ -143,25 +143,25 @@  discard block
 block discarded – undo
143 143
      * @param Translations $to
144 144
      * @param int          $options
145 145
      */
146
-    public static function mergeTranslations(Translations $from, Translations $to, $options = self::DEFAULTS)
146
+    public static function mergeTranslations( Translations $from, Translations $to, $options = self::DEFAULTS )
147 147
     {
148
-        if ($options & self::REMOVE) {
149
-            $filtered = [];
148
+        if ( $options & self::REMOVE ) {
149
+            $filtered = [ ];
150 150
 
151
-            foreach ($to as $entry) {
152
-                if ($from->find($entry)) {
153
-                    $filtered[$entry->getId()] = $entry;
151
+            foreach ( $to as $entry ) {
152
+                if ( $from->find( $entry ) ) {
153
+                    $filtered[ $entry->getId() ] = $entry;
154 154
                 }
155 155
             }
156 156
 
157
-            $to->exchangeArray($filtered);
157
+            $to->exchangeArray( $filtered );
158 158
         }
159 159
 
160
-        foreach ($from as $entry) {
161
-            if (($existing = $to->find($entry))) {
162
-                $existing->mergeWith($entry, $options);
163
-            } elseif ($options & self::ADD) {
164
-                $to[] = $entry->getClone();
160
+        foreach ( $from as $entry ) {
161
+            if ( ( $existing = $to->find( $entry ) ) ) {
162
+                $existing->mergeWith( $entry, $options );
163
+            } elseif ( $options & self::ADD ) {
164
+                $to[ ] = $entry->getClone();
165 165
             }
166 166
         }
167 167
     }
@@ -173,47 +173,47 @@  discard block
 block discarded – undo
173 173
      * @param Translations $to
174 174
      * @param int          $options
175 175
      */
176
-    public static function mergeHeaders(Translations $from, Translations $to, $options = self::DEFAULTS)
176
+    public static function mergeHeaders( Translations $from, Translations $to, $options = self::DEFAULTS )
177 177
     {
178
-        if ($options & self::HEADERS_REMOVE) {
179
-            foreach (array_keys($to->getHeaders()) as $name) {
180
-                if ($from->getHeader($name) === null) {
181
-                    $to->deleteHeader($name);
178
+        if ( $options & self::HEADERS_REMOVE ) {
179
+            foreach ( array_keys( $to->getHeaders() ) as $name ) {
180
+                if ( $from->getHeader( $name ) === null ) {
181
+                    $to->deleteHeader( $name );
182 182
                 }
183 183
             }
184 184
         }
185 185
 
186
-        foreach ($from->getHeaders() as $name => $value) {
187
-            $current = $to->getHeader($name);
186
+        foreach ( $from->getHeaders() as $name => $value ) {
187
+            $current = $to->getHeader( $name );
188 188
 
189
-            if (empty($current)) {
190
-                if ($options & self::HEADERS_ADD) {
191
-                    $to->setHeader($name, $value);
189
+            if ( empty( $current ) ) {
190
+                if ( $options & self::HEADERS_ADD ) {
191
+                    $to->setHeader( $name, $value );
192 192
                 }
193 193
                 continue;
194 194
             }
195 195
 
196
-            if (empty($value)) {
196
+            if ( empty( $value ) ) {
197 197
                 continue;
198 198
             }
199 199
 
200
-            switch ($name) {
200
+            switch ( $name ) {
201 201
                 case Translations::HEADER_LANGUAGE:
202 202
                 case Translations::HEADER_PLURAL:
203
-                    if ($options & self::LANGUAGE_OVERRIDE) {
204
-                        $to->setHeader($name, $value);
203
+                    if ( $options & self::LANGUAGE_OVERRIDE ) {
204
+                        $to->setHeader( $name, $value );
205 205
                     }
206 206
                     break;
207 207
 
208 208
                 case Translations::HEADER_DOMAIN:
209
-                    if ($options & self::DOMAIN_OVERRIDE) {
210
-                        $to->setHeader($name, $value);
209
+                    if ( $options & self::DOMAIN_OVERRIDE ) {
210
+                        $to->setHeader( $name, $value );
211 211
                     }
212 212
                     break;
213 213
 
214 214
                 default:
215
-                    if ($options & self::HEADERS_OVERRIDE) {
216
-                        $to->setHeader($name, $value);
215
+                    if ( $options & self::HEADERS_OVERRIDE ) {
216
+                        $to->setHeader( $name, $value );
217 217
                     }
218 218
             }
219 219
         }
Please login to merge, or discard this patch.
Braces   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -5,8 +5,7 @@  discard block
 block discarded – undo
5 5
 /**
6 6
  * Static class with merge contants.
7 7
  */
8
-final class Merge
9
-{
8
+final class Merge {
10 9
     const ADD = 1;
11 10
     const REMOVE = 2;
12 11
 
@@ -39,8 +38,7 @@  discard block
 block discarded – undo
39 38
      * @param Translation $to
40 39
      * @param int         $options
41 40
      */
42
-    public static function mergeFlags(Translation $from, Translation $to, $options = self::DEFAULTS)
43
-    {
41
+    public static function mergeFlags(Translation $from, Translation $to, $options = self::DEFAULTS) {
44 42
         if ($options & self::FLAGS_THEIRS) {
45 43
             $to->deleteFlags();
46 44
         }
@@ -59,8 +57,7 @@  discard block
 block discarded – undo
59 57
      * @param Translation $to
60 58
      * @param int         $options
61 59
      */
62
-    public static function mergeExtractedComments(Translation $from, Translation $to, $options = self::DEFAULTS)
63
-    {
60
+    public static function mergeExtractedComments(Translation $from, Translation $to, $options = self::DEFAULTS) {
64 61
         if ($options & self::EXTRACTED_COMMENTS_THEIRS) {
65 62
             $to->deleteExtractedComments();
66 63
         }
@@ -79,8 +76,7 @@  discard block
 block discarded – undo
79 76
      * @param Translation $to
80 77
      * @param int         $options
81 78
      */
82
-    public static function mergeComments(Translation $from, Translation $to, $options = self::DEFAULTS)
83
-    {
79
+    public static function mergeComments(Translation $from, Translation $to, $options = self::DEFAULTS) {
84 80
         if ($options & self::COMMENTS_THEIRS) {
85 81
             $to->deleteComments();
86 82
         }
@@ -99,8 +95,7 @@  discard block
 block discarded – undo
99 95
      * @param Translation $to
100 96
      * @param int         $options
101 97
      */
102
-    public static function mergeReferences(Translation $from, Translation $to, $options = self::DEFAULTS)
103
-    {
98
+    public static function mergeReferences(Translation $from, Translation $to, $options = self::DEFAULTS) {
104 99
         if ($options & self::REFERENCES_THEIRS) {
105 100
             $to->deleteReferences();
106 101
         }
@@ -119,8 +114,7 @@  discard block
 block discarded – undo
119 114
      * @param Translation $to
120 115
      * @param int         $options
121 116
      */
122
-    public static function mergeTranslation(Translation $from, Translation $to, $options = self::DEFAULTS)
123
-    {
117
+    public static function mergeTranslation(Translation $from, Translation $to, $options = self::DEFAULTS) {
124 118
         $override = (boolean) ($options & self::TRANSLATION_OVERRIDE);
125 119
 
126 120
         if (!$to->hasTranslation() || ($from->hasTranslation() && $override)) {
@@ -143,8 +137,7 @@  discard block
 block discarded – undo
143 137
      * @param Translations $to
144 138
      * @param int          $options
145 139
      */
146
-    public static function mergeTranslations(Translations $from, Translations $to, $options = self::DEFAULTS)
147
-    {
140
+    public static function mergeTranslations(Translations $from, Translations $to, $options = self::DEFAULTS) {
148 141
         if ($options & self::REMOVE) {
149 142
             $filtered = [];
150 143
 
@@ -173,8 +166,7 @@  discard block
 block discarded – undo
173 166
      * @param Translations $to
174 167
      * @param int          $options
175 168
      */
176
-    public static function mergeHeaders(Translations $from, Translations $to, $options = self::DEFAULTS)
177
-    {
169
+    public static function mergeHeaders(Translations $from, Translations $to, $options = self::DEFAULTS) {
178 170
         if ($options & self::HEADERS_REMOVE) {
179 171
             foreach (array_keys($to->getHeaders()) as $name) {
180 172
                 if ($from->getHeader($name) === null) {
Please login to merge, or discard this patch.
vendor/gettext/gettext/src/autoloader.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 spl_autoload_register(function ($class) {
4
-    if (strpos($class, 'Gettext\\') !== 0) {
5
-        return;
6
-    }
4
+	if (strpos($class, 'Gettext\\') !== 0) {
5
+		return;
6
+	}
7 7
 
8
-    $file = __DIR__.str_replace('\\', DIRECTORY_SEPARATOR, substr($class, strlen('Gettext'))).'.php';
8
+	$file = __DIR__.str_replace('\\', DIRECTORY_SEPARATOR, substr($class, strlen('Gettext'))).'.php';
9 9
 
10
-    if (is_file($file)) {
11
-        require_once $file;
12
-    }
10
+	if (is_file($file)) {
11
+		require_once $file;
12
+	}
13 13
 });
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-spl_autoload_register(function ($class) {
4
-    if (strpos($class, 'Gettext\\') !== 0) {
3
+spl_autoload_register( function( $class ) {
4
+    if ( strpos( $class, 'Gettext\\' ) !== 0 ) {
5 5
         return;
6 6
     }
7 7
 
8
-    $file = __DIR__.str_replace('\\', DIRECTORY_SEPARATOR, substr($class, strlen('Gettext'))).'.php';
8
+    $file = __DIR__ . str_replace( '\\', DIRECTORY_SEPARATOR, substr( $class, strlen( 'Gettext' ) ) ) . '.php';
9 9
 
10
-    if (is_file($file)) {
10
+    if ( is_file( $file ) ) {
11 11
         require_once $file;
12 12
     }
13 13
 });
Please login to merge, or discard this patch.
vendor/gettext/gettext/src/Translator.php 3 patches
Indentation   +250 added lines, -250 removed lines patch added patch discarded remove patch
@@ -6,265 +6,265 @@
 block discarded – undo
6 6
 
7 7
 class Translator extends BaseTranslator implements TranslatorInterface
8 8
 {
9
-    protected $domain;
10
-    protected $dictionary = [];
11
-    protected $plurals = [];
12
-
13
-    /**
14
-     * Loads translation from a Translations instance, a file on an array.
15
-     *
16
-     * @param Translations|string|array $translations
17
-     *
18
-     * @return static
19
-     */
20
-    public function loadTranslations($translations)
21
-    {
22
-        if (is_object($translations) && $translations instanceof Translations) {
23
-            $translations = PhpArray::generate($translations, ['includeHeaders' => false]);
24
-        } elseif (is_string($translations) && is_file($translations)) {
25
-            $translations = include $translations;
26
-        } elseif (!is_array($translations)) {
27
-            throw new \InvalidArgumentException(
28
-                'Invalid Translator: only arrays, files or instance of Translations are allowed'
29
-            );
30
-        }
31
-
32
-        $this->addTranslations($translations);
33
-
34
-        return $this;
35
-    }
36
-
37
-    /**
38
-     * Set the default domain.
39
-     *
40
-     * @param string $domain
41
-     *
42
-     * @return static
43
-     */
44
-    public function defaultDomain($domain)
45
-    {
46
-        $this->domain = $domain;
47
-
48
-        return $this;
49
-    }
50
-
51
-    /**
52
-     * @see TranslatorInterface
53
-     *
54
-     * {@inheritdoc}
55
-     */
56
-    public function gettext($original)
57
-    {
58
-        return $this->dpgettext($this->domain, null, $original);
59
-    }
60
-
61
-    /**
62
-     * @see TranslatorInterface
63
-     *
64
-     * {@inheritdoc}
65
-     */
66
-    public function ngettext($original, $plural, $value)
67
-    {
68
-        return $this->dnpgettext($this->domain, null, $original, $plural, $value);
69
-    }
70
-
71
-    /**
72
-     * @see TranslatorInterface
73
-     *
74
-     * {@inheritdoc}
75
-     */
76
-    public function dngettext($domain, $original, $plural, $value)
77
-    {
78
-        return $this->dnpgettext($domain, null, $original, $plural, $value);
79
-    }
80
-
81
-    /**
82
-     * @see TranslatorInterface
83
-     *
84
-     * {@inheritdoc}
85
-     */
86
-    public function npgettext($context, $original, $plural, $value)
87
-    {
88
-        return $this->dnpgettext($this->domain, $context, $original, $plural, $value);
89
-    }
90
-
91
-    /**
92
-     * @see TranslatorInterface
93
-     *
94
-     * {@inheritdoc}
95
-     */
96
-    public function pgettext($context, $original)
97
-    {
98
-        return $this->dpgettext($this->domain, $context, $original);
99
-    }
100
-
101
-    /**
102
-     * @see TranslatorInterface
103
-     *
104
-     * {@inheritdoc}
105
-     */
106
-    public function dgettext($domain, $original)
107
-    {
108
-        return $this->dpgettext($domain, null, $original);
109
-    }
110
-
111
-    /**
112
-     * @see TranslatorInterface
113
-     *
114
-     * {@inheritdoc}
115
-     */
116
-    public function dpgettext($domain, $context, $original)
117
-    {
118
-        $translation = $this->getTranslation($domain, $context, $original);
119
-
120
-        if (isset($translation[0]) && $translation[0] !== '') {
121
-            return $translation[0];
122
-        }
123
-
124
-        return $original;
125
-    }
126
-
127
-    /**
128
-     * @see TranslatorInterface
129
-     *
130
-     * {@inheritdoc}
131
-     */
132
-    public function dnpgettext($domain, $context, $original, $plural, $value)
133
-    {
134
-        $translation = $this->getTranslation($domain, $context, $original);
135
-        $key = $this->getPluralIndex($domain, $value, $translation === false);
136
-
137
-        if (isset($translation[$key]) && $translation[$key] !== '') {
138
-            return $translation[$key];
139
-        }
140
-
141
-        return ($key === 0) ? $original : $plural;
142
-    }
143
-
144
-    /**
145
-     * Set new translations to the dictionary.
146
-     *
147
-     * @param array $translations
148
-     */
149
-    protected function addTranslations(array $translations)
150
-    {
151
-        $domain = isset($translations['domain']) ? $translations['domain'] : '';
152
-
153
-        //Set the first domain loaded as default domain
154
-        if ($this->domain === null) {
155
-            $this->domain = $domain;
156
-        }
157
-
158
-        if (isset($this->dictionary[$domain])) {
159
-            $this->dictionary[$domain] = array_replace_recursive($this->dictionary[$domain], $translations['messages']);
160
-
161
-            return;
162
-        }
163
-
164
-        if (!empty($translations['plural-forms'])) {
165
-            list($count, $code) = array_map('trim', explode(';', $translations['plural-forms'], 2));
166
-
167
-            // extract just the expression turn 'n' into a php variable '$n'.
168
-            // Slap on a return keyword and semicolon at the end.
169
-            $this->plurals[$domain] = [
170
-                'count' => (int) str_replace('nplurals=', '', $count),
171
-                'code' => str_replace('plural=', 'return ', str_replace('n', '$n', $code)).';',
172
-            ];
173
-        }
174
-
175
-        $this->dictionary[$domain] = $translations['messages'];
176
-    }
177
-
178
-    /**
179
-     * Search and returns a translation.
180
-     *
181
-     * @param string $domain
182
-     * @param string $context
183
-     * @param string $original
184
-     *
185
-     * @return string|false
186
-     */
187
-    protected function getTranslation($domain, $context, $original)
188
-    {
189
-        return isset($this->dictionary[$domain][$context][$original])
190
-             ? $this->dictionary[$domain][$context][$original]
191
-             : false;
192
-    }
193
-
194
-    /**
195
-     * Executes the plural decision code given the number to decide which
196
-     * plural version to take.
197
-     *
198
-     * @param string $domain
199
-     * @param string $n
200
-     * @param bool   $fallback set to true to get fallback plural index
201
-     *
202
-     * @return int
203
-     */
204
-    protected function getPluralIndex($domain, $n, $fallback)
205
-    {
206
-        //Not loaded domain or translation, use a fallback
207
-        if (!isset($this->plurals[$domain]) || $fallback === true) {
208
-            return $n == 1 ? 0 : 1;
209
-        }
210
-
211
-        if (!isset($this->plurals[$domain]['function'])) {
212
-            $code = static::fixTerseIfs($this->plurals[$domain]['code']);
213
-            $this->plurals[$domain]['function'] = eval("return function (\$n) { $code };");
214
-        }
215
-
216
-        if ($this->plurals[$domain]['count'] <= 2) {
217
-            return call_user_func($this->plurals[$domain]['function'], $n) ? 1 : 0;
218
-        }
219
-
220
-        return call_user_func($this->plurals[$domain]['function'], $n);
221
-    }
222
-
223
-    /**
224
-     * This function will recursively wrap failure states in brackets if they contain a nested terse if.
225
-     *
226
-     * This because PHP can not handle nested terse if's unless they are wrapped in brackets.
227
-     *
228
-     * This code probably only works for the gettext plural decision codes.
229
-     *
230
-     * return ($n==1 ? 0 : $n%10>=2 && $n%10<=4 && ($n%100<10 || $n%100>=20) ? 1 : 2);
231
-     * becomes
232
-     * return ($n==1 ? 0 : ($n%10>=2 && $n%10<=4 && ($n%100<10 || $n%100>=20) ? 1 : 2));
233
-     *
234
-     * @param string $code  the terse if string
235
-     * @param bool   $inner If inner is true we wrap it in brackets
236
-     *
237
-     * @return string A formatted terse If that PHP can work with.
238
-     */
239
-    private static function fixTerseIfs($code, $inner = false)
240
-    {
241
-        /*
9
+	protected $domain;
10
+	protected $dictionary = [];
11
+	protected $plurals = [];
12
+
13
+	/**
14
+	 * Loads translation from a Translations instance, a file on an array.
15
+	 *
16
+	 * @param Translations|string|array $translations
17
+	 *
18
+	 * @return static
19
+	 */
20
+	public function loadTranslations($translations)
21
+	{
22
+		if (is_object($translations) && $translations instanceof Translations) {
23
+			$translations = PhpArray::generate($translations, ['includeHeaders' => false]);
24
+		} elseif (is_string($translations) && is_file($translations)) {
25
+			$translations = include $translations;
26
+		} elseif (!is_array($translations)) {
27
+			throw new \InvalidArgumentException(
28
+				'Invalid Translator: only arrays, files or instance of Translations are allowed'
29
+			);
30
+		}
31
+
32
+		$this->addTranslations($translations);
33
+
34
+		return $this;
35
+	}
36
+
37
+	/**
38
+	 * Set the default domain.
39
+	 *
40
+	 * @param string $domain
41
+	 *
42
+	 * @return static
43
+	 */
44
+	public function defaultDomain($domain)
45
+	{
46
+		$this->domain = $domain;
47
+
48
+		return $this;
49
+	}
50
+
51
+	/**
52
+	 * @see TranslatorInterface
53
+	 *
54
+	 * {@inheritdoc}
55
+	 */
56
+	public function gettext($original)
57
+	{
58
+		return $this->dpgettext($this->domain, null, $original);
59
+	}
60
+
61
+	/**
62
+	 * @see TranslatorInterface
63
+	 *
64
+	 * {@inheritdoc}
65
+	 */
66
+	public function ngettext($original, $plural, $value)
67
+	{
68
+		return $this->dnpgettext($this->domain, null, $original, $plural, $value);
69
+	}
70
+
71
+	/**
72
+	 * @see TranslatorInterface
73
+	 *
74
+	 * {@inheritdoc}
75
+	 */
76
+	public function dngettext($domain, $original, $plural, $value)
77
+	{
78
+		return $this->dnpgettext($domain, null, $original, $plural, $value);
79
+	}
80
+
81
+	/**
82
+	 * @see TranslatorInterface
83
+	 *
84
+	 * {@inheritdoc}
85
+	 */
86
+	public function npgettext($context, $original, $plural, $value)
87
+	{
88
+		return $this->dnpgettext($this->domain, $context, $original, $plural, $value);
89
+	}
90
+
91
+	/**
92
+	 * @see TranslatorInterface
93
+	 *
94
+	 * {@inheritdoc}
95
+	 */
96
+	public function pgettext($context, $original)
97
+	{
98
+		return $this->dpgettext($this->domain, $context, $original);
99
+	}
100
+
101
+	/**
102
+	 * @see TranslatorInterface
103
+	 *
104
+	 * {@inheritdoc}
105
+	 */
106
+	public function dgettext($domain, $original)
107
+	{
108
+		return $this->dpgettext($domain, null, $original);
109
+	}
110
+
111
+	/**
112
+	 * @see TranslatorInterface
113
+	 *
114
+	 * {@inheritdoc}
115
+	 */
116
+	public function dpgettext($domain, $context, $original)
117
+	{
118
+		$translation = $this->getTranslation($domain, $context, $original);
119
+
120
+		if (isset($translation[0]) && $translation[0] !== '') {
121
+			return $translation[0];
122
+		}
123
+
124
+		return $original;
125
+	}
126
+
127
+	/**
128
+	 * @see TranslatorInterface
129
+	 *
130
+	 * {@inheritdoc}
131
+	 */
132
+	public function dnpgettext($domain, $context, $original, $plural, $value)
133
+	{
134
+		$translation = $this->getTranslation($domain, $context, $original);
135
+		$key = $this->getPluralIndex($domain, $value, $translation === false);
136
+
137
+		if (isset($translation[$key]) && $translation[$key] !== '') {
138
+			return $translation[$key];
139
+		}
140
+
141
+		return ($key === 0) ? $original : $plural;
142
+	}
143
+
144
+	/**
145
+	 * Set new translations to the dictionary.
146
+	 *
147
+	 * @param array $translations
148
+	 */
149
+	protected function addTranslations(array $translations)
150
+	{
151
+		$domain = isset($translations['domain']) ? $translations['domain'] : '';
152
+
153
+		//Set the first domain loaded as default domain
154
+		if ($this->domain === null) {
155
+			$this->domain = $domain;
156
+		}
157
+
158
+		if (isset($this->dictionary[$domain])) {
159
+			$this->dictionary[$domain] = array_replace_recursive($this->dictionary[$domain], $translations['messages']);
160
+
161
+			return;
162
+		}
163
+
164
+		if (!empty($translations['plural-forms'])) {
165
+			list($count, $code) = array_map('trim', explode(';', $translations['plural-forms'], 2));
166
+
167
+			// extract just the expression turn 'n' into a php variable '$n'.
168
+			// Slap on a return keyword and semicolon at the end.
169
+			$this->plurals[$domain] = [
170
+				'count' => (int) str_replace('nplurals=', '', $count),
171
+				'code' => str_replace('plural=', 'return ', str_replace('n', '$n', $code)).';',
172
+			];
173
+		}
174
+
175
+		$this->dictionary[$domain] = $translations['messages'];
176
+	}
177
+
178
+	/**
179
+	 * Search and returns a translation.
180
+	 *
181
+	 * @param string $domain
182
+	 * @param string $context
183
+	 * @param string $original
184
+	 *
185
+	 * @return string|false
186
+	 */
187
+	protected function getTranslation($domain, $context, $original)
188
+	{
189
+		return isset($this->dictionary[$domain][$context][$original])
190
+			 ? $this->dictionary[$domain][$context][$original]
191
+			 : false;
192
+	}
193
+
194
+	/**
195
+	 * Executes the plural decision code given the number to decide which
196
+	 * plural version to take.
197
+	 *
198
+	 * @param string $domain
199
+	 * @param string $n
200
+	 * @param bool   $fallback set to true to get fallback plural index
201
+	 *
202
+	 * @return int
203
+	 */
204
+	protected function getPluralIndex($domain, $n, $fallback)
205
+	{
206
+		//Not loaded domain or translation, use a fallback
207
+		if (!isset($this->plurals[$domain]) || $fallback === true) {
208
+			return $n == 1 ? 0 : 1;
209
+		}
210
+
211
+		if (!isset($this->plurals[$domain]['function'])) {
212
+			$code = static::fixTerseIfs($this->plurals[$domain]['code']);
213
+			$this->plurals[$domain]['function'] = eval("return function (\$n) { $code };");
214
+		}
215
+
216
+		if ($this->plurals[$domain]['count'] <= 2) {
217
+			return call_user_func($this->plurals[$domain]['function'], $n) ? 1 : 0;
218
+		}
219
+
220
+		return call_user_func($this->plurals[$domain]['function'], $n);
221
+	}
222
+
223
+	/**
224
+	 * This function will recursively wrap failure states in brackets if they contain a nested terse if.
225
+	 *
226
+	 * This because PHP can not handle nested terse if's unless they are wrapped in brackets.
227
+	 *
228
+	 * This code probably only works for the gettext plural decision codes.
229
+	 *
230
+	 * return ($n==1 ? 0 : $n%10>=2 && $n%10<=4 && ($n%100<10 || $n%100>=20) ? 1 : 2);
231
+	 * becomes
232
+	 * return ($n==1 ? 0 : ($n%10>=2 && $n%10<=4 && ($n%100<10 || $n%100>=20) ? 1 : 2));
233
+	 *
234
+	 * @param string $code  the terse if string
235
+	 * @param bool   $inner If inner is true we wrap it in brackets
236
+	 *
237
+	 * @return string A formatted terse If that PHP can work with.
238
+	 */
239
+	private static function fixTerseIfs($code, $inner = false)
240
+	{
241
+		/*
242 242
          * (?P<expression>[^?]+)   Capture everything up to ? as 'expression'
243 243
          * \?                      ?
244 244
          * (?P<success>[^:]+)      Capture everything up to : as 'success'
245 245
          * :                       :
246 246
          * (?P<failure>[^;]+)      Capture everything up to ; as 'failure'
247 247
          */
248
-        preg_match('/(?P<expression>[^?]+)\?(?P<success>[^:]+):(?P<failure>[^;]+)/', $code, $matches);
248
+		preg_match('/(?P<expression>[^?]+)\?(?P<success>[^:]+):(?P<failure>[^;]+)/', $code, $matches);
249 249
 
250
-        // If no match was found then no terse if was present
251
-        if (!isset($matches[0])) {
252
-            return $code;
253
-        }
250
+		// If no match was found then no terse if was present
251
+		if (!isset($matches[0])) {
252
+			return $code;
253
+		}
254 254
 
255
-        $expression = $matches['expression'];
256
-        $success = $matches['success'];
257
-        $failure = $matches['failure'];
255
+		$expression = $matches['expression'];
256
+		$success = $matches['success'];
257
+		$failure = $matches['failure'];
258 258
 
259
-        // Go look for another terse if in the failure state.
260
-        $failure = static::fixTerseIfs($failure, true);
261
-        $code = $expression.' ? '.$success.' : '.$failure;
259
+		// Go look for another terse if in the failure state.
260
+		$failure = static::fixTerseIfs($failure, true);
261
+		$code = $expression.' ? '.$success.' : '.$failure;
262 262
 
263
-        if ($inner) {
264
-            return "($code)";
265
-        }
263
+		if ($inner) {
264
+			return "($code)";
265
+		}
266 266
 
267
-        // note the semicolon. We need that for executing the code.
268
-        return "$code;";
269
-    }
267
+		// note the semicolon. We need that for executing the code.
268
+		return "$code;";
269
+	}
270 270
 }
Please login to merge, or discard this patch.
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
 class Translator extends BaseTranslator implements TranslatorInterface
8 8
 {
9 9
     protected $domain;
10
-    protected $dictionary = [];
11
-    protected $plurals = [];
10
+    protected $dictionary = [ ];
11
+    protected $plurals = [ ];
12 12
 
13 13
     /**
14 14
      * Loads translation from a Translations instance, a file on an array.
@@ -17,19 +17,19 @@  discard block
 block discarded – undo
17 17
      *
18 18
      * @return static
19 19
      */
20
-    public function loadTranslations($translations)
20
+    public function loadTranslations( $translations )
21 21
     {
22
-        if (is_object($translations) && $translations instanceof Translations) {
23
-            $translations = PhpArray::generate($translations, ['includeHeaders' => false]);
24
-        } elseif (is_string($translations) && is_file($translations)) {
22
+        if ( is_object( $translations ) && $translations instanceof Translations ) {
23
+            $translations = PhpArray::generate( $translations, [ 'includeHeaders' => false ] );
24
+        } elseif ( is_string( $translations ) && is_file( $translations ) ) {
25 25
             $translations = include $translations;
26
-        } elseif (!is_array($translations)) {
26
+        } elseif ( ! is_array( $translations ) ) {
27 27
             throw new \InvalidArgumentException(
28 28
                 'Invalid Translator: only arrays, files or instance of Translations are allowed'
29 29
             );
30 30
         }
31 31
 
32
-        $this->addTranslations($translations);
32
+        $this->addTranslations( $translations );
33 33
 
34 34
         return $this;
35 35
     }
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      *
42 42
      * @return static
43 43
      */
44
-    public function defaultDomain($domain)
44
+    public function defaultDomain( $domain )
45 45
     {
46 46
         $this->domain = $domain;
47 47
 
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
      *
54 54
      * {@inheritdoc}
55 55
      */
56
-    public function gettext($original)
56
+    public function gettext( $original )
57 57
     {
58
-        return $this->dpgettext($this->domain, null, $original);
58
+        return $this->dpgettext( $this->domain, null, $original );
59 59
     }
60 60
 
61 61
     /**
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
      *
64 64
      * {@inheritdoc}
65 65
      */
66
-    public function ngettext($original, $plural, $value)
66
+    public function ngettext( $original, $plural, $value )
67 67
     {
68
-        return $this->dnpgettext($this->domain, null, $original, $plural, $value);
68
+        return $this->dnpgettext( $this->domain, null, $original, $plural, $value );
69 69
     }
70 70
 
71 71
     /**
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
      *
74 74
      * {@inheritdoc}
75 75
      */
76
-    public function dngettext($domain, $original, $plural, $value)
76
+    public function dngettext( $domain, $original, $plural, $value )
77 77
     {
78
-        return $this->dnpgettext($domain, null, $original, $plural, $value);
78
+        return $this->dnpgettext( $domain, null, $original, $plural, $value );
79 79
     }
80 80
 
81 81
     /**
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
      *
84 84
      * {@inheritdoc}
85 85
      */
86
-    public function npgettext($context, $original, $plural, $value)
86
+    public function npgettext( $context, $original, $plural, $value )
87 87
     {
88
-        return $this->dnpgettext($this->domain, $context, $original, $plural, $value);
88
+        return $this->dnpgettext( $this->domain, $context, $original, $plural, $value );
89 89
     }
90 90
 
91 91
     /**
@@ -93,9 +93,9 @@  discard block
 block discarded – undo
93 93
      *
94 94
      * {@inheritdoc}
95 95
      */
96
-    public function pgettext($context, $original)
96
+    public function pgettext( $context, $original )
97 97
     {
98
-        return $this->dpgettext($this->domain, $context, $original);
98
+        return $this->dpgettext( $this->domain, $context, $original );
99 99
     }
100 100
 
101 101
     /**
@@ -103,9 +103,9 @@  discard block
 block discarded – undo
103 103
      *
104 104
      * {@inheritdoc}
105 105
      */
106
-    public function dgettext($domain, $original)
106
+    public function dgettext( $domain, $original )
107 107
     {
108
-        return $this->dpgettext($domain, null, $original);
108
+        return $this->dpgettext( $domain, null, $original );
109 109
     }
110 110
 
111 111
     /**
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
      *
114 114
      * {@inheritdoc}
115 115
      */
116
-    public function dpgettext($domain, $context, $original)
116
+    public function dpgettext( $domain, $context, $original )
117 117
     {
118
-        $translation = $this->getTranslation($domain, $context, $original);
118
+        $translation = $this->getTranslation( $domain, $context, $original );
119 119
 
120
-        if (isset($translation[0]) && $translation[0] !== '') {
121
-            return $translation[0];
120
+        if ( isset( $translation[ 0 ] ) && $translation[ 0 ] !== '' ) {
121
+            return $translation[ 0 ];
122 122
         }
123 123
 
124 124
         return $original;
@@ -129,16 +129,16 @@  discard block
 block discarded – undo
129 129
      *
130 130
      * {@inheritdoc}
131 131
      */
132
-    public function dnpgettext($domain, $context, $original, $plural, $value)
132
+    public function dnpgettext( $domain, $context, $original, $plural, $value )
133 133
     {
134
-        $translation = $this->getTranslation($domain, $context, $original);
135
-        $key = $this->getPluralIndex($domain, $value, $translation === false);
134
+        $translation = $this->getTranslation( $domain, $context, $original );
135
+        $key = $this->getPluralIndex( $domain, $value, $translation === false );
136 136
 
137
-        if (isset($translation[$key]) && $translation[$key] !== '') {
138
-            return $translation[$key];
137
+        if ( isset( $translation[ $key ] ) && $translation[ $key ] !== '' ) {
138
+            return $translation[ $key ];
139 139
         }
140 140
 
141
-        return ($key === 0) ? $original : $plural;
141
+        return ( $key === 0 ) ? $original : $plural;
142 142
     }
143 143
 
144 144
     /**
@@ -146,33 +146,33 @@  discard block
 block discarded – undo
146 146
      *
147 147
      * @param array $translations
148 148
      */
149
-    protected function addTranslations(array $translations)
149
+    protected function addTranslations( array $translations )
150 150
     {
151
-        $domain = isset($translations['domain']) ? $translations['domain'] : '';
151
+        $domain = isset( $translations[ 'domain' ] ) ? $translations[ 'domain' ] : '';
152 152
 
153 153
         //Set the first domain loaded as default domain
154
-        if ($this->domain === null) {
154
+        if ( $this->domain === null ) {
155 155
             $this->domain = $domain;
156 156
         }
157 157
 
158
-        if (isset($this->dictionary[$domain])) {
159
-            $this->dictionary[$domain] = array_replace_recursive($this->dictionary[$domain], $translations['messages']);
158
+        if ( isset( $this->dictionary[ $domain ] ) ) {
159
+            $this->dictionary[ $domain ] = array_replace_recursive( $this->dictionary[ $domain ], $translations[ 'messages' ] );
160 160
 
161 161
             return;
162 162
         }
163 163
 
164
-        if (!empty($translations['plural-forms'])) {
165
-            list($count, $code) = array_map('trim', explode(';', $translations['plural-forms'], 2));
164
+        if ( ! empty( $translations[ 'plural-forms' ] ) ) {
165
+            list( $count, $code ) = array_map( 'trim', explode( ';', $translations[ 'plural-forms' ], 2 ) );
166 166
 
167 167
             // extract just the expression turn 'n' into a php variable '$n'.
168 168
             // Slap on a return keyword and semicolon at the end.
169
-            $this->plurals[$domain] = [
170
-                'count' => (int) str_replace('nplurals=', '', $count),
171
-                'code' => str_replace('plural=', 'return ', str_replace('n', '$n', $code)).';',
169
+            $this->plurals[ $domain ] = [
170
+                'count' => (int)str_replace( 'nplurals=', '', $count ),
171
+                'code' => str_replace( 'plural=', 'return ', str_replace( 'n', '$n', $code ) ) . ';',
172 172
             ];
173 173
         }
174 174
 
175
-        $this->dictionary[$domain] = $translations['messages'];
175
+        $this->dictionary[ $domain ] = $translations[ 'messages' ];
176 176
     }
177 177
 
178 178
     /**
@@ -184,10 +184,10 @@  discard block
 block discarded – undo
184 184
      *
185 185
      * @return string|false
186 186
      */
187
-    protected function getTranslation($domain, $context, $original)
187
+    protected function getTranslation( $domain, $context, $original )
188 188
     {
189
-        return isset($this->dictionary[$domain][$context][$original])
190
-             ? $this->dictionary[$domain][$context][$original]
189
+        return isset( $this->dictionary[ $domain ][ $context ][ $original ] )
190
+             ? $this->dictionary[ $domain ][ $context ][ $original ]
191 191
              : false;
192 192
     }
193 193
 
@@ -201,23 +201,23 @@  discard block
 block discarded – undo
201 201
      *
202 202
      * @return int
203 203
      */
204
-    protected function getPluralIndex($domain, $n, $fallback)
204
+    protected function getPluralIndex( $domain, $n, $fallback )
205 205
     {
206 206
         //Not loaded domain or translation, use a fallback
207
-        if (!isset($this->plurals[$domain]) || $fallback === true) {
207
+        if ( ! isset( $this->plurals[ $domain ] ) || $fallback === true ) {
208 208
             return $n == 1 ? 0 : 1;
209 209
         }
210 210
 
211
-        if (!isset($this->plurals[$domain]['function'])) {
212
-            $code = static::fixTerseIfs($this->plurals[$domain]['code']);
213
-            $this->plurals[$domain]['function'] = eval("return function (\$n) { $code };");
211
+        if ( ! isset( $this->plurals[ $domain ][ 'function' ] ) ) {
212
+            $code = static::fixTerseIfs( $this->plurals[ $domain ][ 'code' ] );
213
+            $this->plurals[ $domain ][ 'function' ] = eval( "return function (\$n) { $code };" );
214 214
         }
215 215
 
216
-        if ($this->plurals[$domain]['count'] <= 2) {
217
-            return call_user_func($this->plurals[$domain]['function'], $n) ? 1 : 0;
216
+        if ( $this->plurals[ $domain ][ 'count' ] <= 2 ) {
217
+            return call_user_func( $this->plurals[ $domain ][ 'function' ], $n ) ? 1 : 0;
218 218
         }
219 219
 
220
-        return call_user_func($this->plurals[$domain]['function'], $n);
220
+        return call_user_func( $this->plurals[ $domain ][ 'function' ], $n );
221 221
     }
222 222
 
223 223
     /**
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
      *
237 237
      * @return string A formatted terse If that PHP can work with.
238 238
      */
239
-    private static function fixTerseIfs($code, $inner = false)
239
+    private static function fixTerseIfs( $code, $inner = false )
240 240
     {
241 241
         /*
242 242
          * (?P<expression>[^?]+)   Capture everything up to ? as 'expression'
@@ -245,22 +245,22 @@  discard block
 block discarded – undo
245 245
          * :                       :
246 246
          * (?P<failure>[^;]+)      Capture everything up to ; as 'failure'
247 247
          */
248
-        preg_match('/(?P<expression>[^?]+)\?(?P<success>[^:]+):(?P<failure>[^;]+)/', $code, $matches);
248
+        preg_match( '/(?P<expression>[^?]+)\?(?P<success>[^:]+):(?P<failure>[^;]+)/', $code, $matches );
249 249
 
250 250
         // If no match was found then no terse if was present
251
-        if (!isset($matches[0])) {
251
+        if ( ! isset( $matches[ 0 ] ) ) {
252 252
             return $code;
253 253
         }
254 254
 
255
-        $expression = $matches['expression'];
256
-        $success = $matches['success'];
257
-        $failure = $matches['failure'];
255
+        $expression = $matches[ 'expression' ];
256
+        $success = $matches[ 'success' ];
257
+        $failure = $matches[ 'failure' ];
258 258
 
259 259
         // Go look for another terse if in the failure state.
260
-        $failure = static::fixTerseIfs($failure, true);
261
-        $code = $expression.' ? '.$success.' : '.$failure;
260
+        $failure = static::fixTerseIfs( $failure, true );
261
+        $code = $expression . ' ? ' . $success . ' : ' . $failure;
262 262
 
263
-        if ($inner) {
263
+        if ( $inner ) {
264 264
             return "($code)";
265 265
         }
266 266
 
Please login to merge, or discard this patch.
Braces   +15 added lines, -30 removed lines patch added patch discarded remove patch
@@ -4,8 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 use Gettext\Generators\PhpArray;
6 6
 
7
-class Translator extends BaseTranslator implements TranslatorInterface
8
-{
7
+class Translator extends BaseTranslator implements TranslatorInterface {
9 8
     protected $domain;
10 9
     protected $dictionary = [];
11 10
     protected $plurals = [];
@@ -17,8 +16,7 @@  discard block
 block discarded – undo
17 16
      *
18 17
      * @return static
19 18
      */
20
-    public function loadTranslations($translations)
21
-    {
19
+    public function loadTranslations($translations) {
22 20
         if (is_object($translations) && $translations instanceof Translations) {
23 21
             $translations = PhpArray::generate($translations, ['includeHeaders' => false]);
24 22
         } elseif (is_string($translations) && is_file($translations)) {
@@ -41,8 +39,7 @@  discard block
 block discarded – undo
41 39
      *
42 40
      * @return static
43 41
      */
44
-    public function defaultDomain($domain)
45
-    {
42
+    public function defaultDomain($domain) {
46 43
         $this->domain = $domain;
47 44
 
48 45
         return $this;
@@ -53,8 +50,7 @@  discard block
 block discarded – undo
53 50
      *
54 51
      * {@inheritdoc}
55 52
      */
56
-    public function gettext($original)
57
-    {
53
+    public function gettext($original) {
58 54
         return $this->dpgettext($this->domain, null, $original);
59 55
     }
60 56
 
@@ -63,8 +59,7 @@  discard block
 block discarded – undo
63 59
      *
64 60
      * {@inheritdoc}
65 61
      */
66
-    public function ngettext($original, $plural, $value)
67
-    {
62
+    public function ngettext($original, $plural, $value) {
68 63
         return $this->dnpgettext($this->domain, null, $original, $plural, $value);
69 64
     }
70 65
 
@@ -73,8 +68,7 @@  discard block
 block discarded – undo
73 68
      *
74 69
      * {@inheritdoc}
75 70
      */
76
-    public function dngettext($domain, $original, $plural, $value)
77
-    {
71
+    public function dngettext($domain, $original, $plural, $value) {
78 72
         return $this->dnpgettext($domain, null, $original, $plural, $value);
79 73
     }
80 74
 
@@ -83,8 +77,7 @@  discard block
 block discarded – undo
83 77
      *
84 78
      * {@inheritdoc}
85 79
      */
86
-    public function npgettext($context, $original, $plural, $value)
87
-    {
80
+    public function npgettext($context, $original, $plural, $value) {
88 81
         return $this->dnpgettext($this->domain, $context, $original, $plural, $value);
89 82
     }
90 83
 
@@ -93,8 +86,7 @@  discard block
 block discarded – undo
93 86
      *
94 87
      * {@inheritdoc}
95 88
      */
96
-    public function pgettext($context, $original)
97
-    {
89
+    public function pgettext($context, $original) {
98 90
         return $this->dpgettext($this->domain, $context, $original);
99 91
     }
100 92
 
@@ -103,8 +95,7 @@  discard block
 block discarded – undo
103 95
      *
104 96
      * {@inheritdoc}
105 97
      */
106
-    public function dgettext($domain, $original)
107
-    {
98
+    public function dgettext($domain, $original) {
108 99
         return $this->dpgettext($domain, null, $original);
109 100
     }
110 101
 
@@ -113,8 +104,7 @@  discard block
 block discarded – undo
113 104
      *
114 105
      * {@inheritdoc}
115 106
      */
116
-    public function dpgettext($domain, $context, $original)
117
-    {
107
+    public function dpgettext($domain, $context, $original) {
118 108
         $translation = $this->getTranslation($domain, $context, $original);
119 109
 
120 110
         if (isset($translation[0]) && $translation[0] !== '') {
@@ -129,8 +119,7 @@  discard block
 block discarded – undo
129 119
      *
130 120
      * {@inheritdoc}
131 121
      */
132
-    public function dnpgettext($domain, $context, $original, $plural, $value)
133
-    {
122
+    public function dnpgettext($domain, $context, $original, $plural, $value) {
134 123
         $translation = $this->getTranslation($domain, $context, $original);
135 124
         $key = $this->getPluralIndex($domain, $value, $translation === false);
136 125
 
@@ -146,8 +135,7 @@  discard block
 block discarded – undo
146 135
      *
147 136
      * @param array $translations
148 137
      */
149
-    protected function addTranslations(array $translations)
150
-    {
138
+    protected function addTranslations(array $translations) {
151 139
         $domain = isset($translations['domain']) ? $translations['domain'] : '';
152 140
 
153 141
         //Set the first domain loaded as default domain
@@ -184,8 +172,7 @@  discard block
 block discarded – undo
184 172
      *
185 173
      * @return string|false
186 174
      */
187
-    protected function getTranslation($domain, $context, $original)
188
-    {
175
+    protected function getTranslation($domain, $context, $original) {
189 176
         return isset($this->dictionary[$domain][$context][$original])
190 177
              ? $this->dictionary[$domain][$context][$original]
191 178
              : false;
@@ -201,8 +188,7 @@  discard block
 block discarded – undo
201 188
      *
202 189
      * @return int
203 190
      */
204
-    protected function getPluralIndex($domain, $n, $fallback)
205
-    {
191
+    protected function getPluralIndex($domain, $n, $fallback) {
206 192
         //Not loaded domain or translation, use a fallback
207 193
         if (!isset($this->plurals[$domain]) || $fallback === true) {
208 194
             return $n == 1 ? 0 : 1;
@@ -236,8 +222,7 @@  discard block
 block discarded – undo
236 222
      *
237 223
      * @return string A formatted terse If that PHP can work with.
238 224
      */
239
-    private static function fixTerseIfs($code, $inner = false)
240
-    {
225
+    private static function fixTerseIfs($code, $inner = false) {
241 226
         /*
242 227
          * (?P<expression>[^?]+)   Capture everything up to ? as 'expression'
243 228
          * \?                      ?
Please login to merge, or discard this patch.
vendor/gettext/gettext/src/Extractors/PhpArray.php 3 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -11,23 +11,23 @@
 block discarded – undo
11 11
  */
12 12
 class PhpArray extends Extractor implements ExtractorInterface
13 13
 {
14
-    use MultidimensionalArrayTrait;
14
+	use MultidimensionalArrayTrait;
15 15
 
16
-    /**
17
-     * {@inheritdoc}
18
-     */
19
-    public static function fromFile($file, Translations $translations, array $options = [])
20
-    {
21
-        foreach (static::getFiles($file) as $file) {
22
-            static::fromArray(include($file), $translations);
23
-        }
24
-    }
16
+	/**
17
+	 * {@inheritdoc}
18
+	 */
19
+	public static function fromFile($file, Translations $translations, array $options = [])
20
+	{
21
+		foreach (static::getFiles($file) as $file) {
22
+			static::fromArray(include($file), $translations);
23
+		}
24
+	}
25 25
 
26
-    /**
27
-     * {@inheritdoc}
28
-     */
29
-    public static function fromString($string, Translations $translations, array $options = [])
30
-    {
31
-        throw new BadMethodCallException('PhpArray::fromString() cannot be called. Use PhpArray::fromFile()');
32
-    }
26
+	/**
27
+	 * {@inheritdoc}
28
+	 */
29
+	public static function fromString($string, Translations $translations, array $options = [])
30
+	{
31
+		throw new BadMethodCallException('PhpArray::fromString() cannot be called. Use PhpArray::fromFile()');
32
+	}
33 33
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,18 +16,18 @@
 block discarded – undo
16 16
     /**
17 17
      * {@inheritdoc}
18 18
      */
19
-    public static function fromFile($file, Translations $translations, array $options = [])
19
+    public static function fromFile( $file, Translations $translations, array $options = [ ] )
20 20
     {
21
-        foreach (static::getFiles($file) as $file) {
22
-            static::fromArray(include($file), $translations);
21
+        foreach ( static::getFiles( $file ) as $file ) {
22
+            static::fromArray( include( $file ), $translations );
23 23
         }
24 24
     }
25 25
 
26 26
     /**
27 27
      * {@inheritdoc}
28 28
      */
29
-    public static function fromString($string, Translations $translations, array $options = [])
29
+    public static function fromString( $string, Translations $translations, array $options = [ ] )
30 30
     {
31
-        throw new BadMethodCallException('PhpArray::fromString() cannot be called. Use PhpArray::fromFile()');
31
+        throw new BadMethodCallException( 'PhpArray::fromString() cannot be called. Use PhpArray::fromFile()' );
32 32
     }
33 33
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -9,15 +9,13 @@  discard block
 block discarded – undo
9 9
 /**
10 10
  * Class to get gettext strings from php files returning arrays.
11 11
  */
12
-class PhpArray extends Extractor implements ExtractorInterface
13
-{
12
+class PhpArray extends Extractor implements ExtractorInterface {
14 13
     use MultidimensionalArrayTrait;
15 14
 
16 15
     /**
17 16
      * {@inheritdoc}
18 17
      */
19
-    public static function fromFile($file, Translations $translations, array $options = [])
20
-    {
18
+    public static function fromFile($file, Translations $translations, array $options = []) {
21 19
         foreach (static::getFiles($file) as $file) {
22 20
             static::fromArray(include($file), $translations);
23 21
         }
@@ -26,8 +24,7 @@  discard block
 block discarded – undo
26 24
     /**
27 25
      * {@inheritdoc}
28 26
      */
29
-    public static function fromString($string, Translations $translations, array $options = [])
30
-    {
27
+    public static function fromString($string, Translations $translations, array $options = []) {
31 28
         throw new BadMethodCallException('PhpArray::fromString() cannot be called. Use PhpArray::fromFile()');
32 29
     }
33 30
 }
Please login to merge, or discard this patch.
vendor/gettext/gettext/src/Extractors/CsvDictionary.php 3 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -11,37 +11,37 @@
 block discarded – undo
11 11
  */
12 12
 class CsvDictionary extends Extractor implements ExtractorInterface
13 13
 {
14
-    use HeadersExtractorTrait;
15
-    use CsvTrait;
16
-
17
-    public static $options = [
18
-        'delimiter' => ",",
19
-        'enclosure' => '"',
20
-        'escape_char' => "\\"
21
-    ];
22
-
23
-    /**
24
-     * {@inheritdoc}
25
-     */
26
-    public static function fromString($string, Translations $translations, array $options = [])
27
-    {
28
-        $options += static::$options;
29
-        $handle = fopen('php://memory', 'w');
30
-
31
-        fputs($handle, $string);
32
-        rewind($handle);
33
-
34
-        while ($row = static::fgetcsv($handle, $options)) {
35
-            list($original, $translation) = $row + ['', ''];
36
-
37
-            if ($original === '') {
38
-                static::extractHeaders($translation, $translations);
39
-                continue;
40
-            }
41
-
42
-            $translations->insert(null, $original)->setTranslation($translation);
43
-        }
44
-
45
-        fclose($handle);
46
-    }
14
+	use HeadersExtractorTrait;
15
+	use CsvTrait;
16
+
17
+	public static $options = [
18
+		'delimiter' => ",",
19
+		'enclosure' => '"',
20
+		'escape_char' => "\\"
21
+	];
22
+
23
+	/**
24
+	 * {@inheritdoc}
25
+	 */
26
+	public static function fromString($string, Translations $translations, array $options = [])
27
+	{
28
+		$options += static::$options;
29
+		$handle = fopen('php://memory', 'w');
30
+
31
+		fputs($handle, $string);
32
+		rewind($handle);
33
+
34
+		while ($row = static::fgetcsv($handle, $options)) {
35
+			list($original, $translation) = $row + ['', ''];
36
+
37
+			if ($original === '') {
38
+				static::extractHeaders($translation, $translations);
39
+				continue;
40
+			}
41
+
42
+			$translations->insert(null, $original)->setTranslation($translation);
43
+		}
44
+
45
+		fclose($handle);
46
+	}
47 47
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -23,25 +23,25 @@
 block discarded – undo
23 23
     /**
24 24
      * {@inheritdoc}
25 25
      */
26
-    public static function fromString($string, Translations $translations, array $options = [])
26
+    public static function fromString( $string, Translations $translations, array $options = [ ] )
27 27
     {
28 28
         $options += static::$options;
29
-        $handle = fopen('php://memory', 'w');
29
+        $handle = fopen( 'php://memory', 'w' );
30 30
 
31
-        fputs($handle, $string);
32
-        rewind($handle);
31
+        fputs( $handle, $string );
32
+        rewind( $handle );
33 33
 
34
-        while ($row = static::fgetcsv($handle, $options)) {
35
-            list($original, $translation) = $row + ['', ''];
34
+        while ( $row = static::fgetcsv( $handle, $options ) ) {
35
+            list( $original, $translation ) = $row + [ '', '' ];
36 36
 
37
-            if ($original === '') {
38
-                static::extractHeaders($translation, $translations);
37
+            if ( $original === '' ) {
38
+                static::extractHeaders( $translation, $translations );
39 39
                 continue;
40 40
             }
41 41
 
42
-            $translations->insert(null, $original)->setTranslation($translation);
42
+            $translations->insert( null, $original )->setTranslation( $translation );
43 43
         }
44 44
 
45
-        fclose($handle);
45
+        fclose( $handle );
46 46
     }
47 47
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,8 +9,7 @@  discard block
 block discarded – undo
9 9
 /**
10 10
  * Class to get gettext strings from csv.
11 11
  */
12
-class CsvDictionary extends Extractor implements ExtractorInterface
13
-{
12
+class CsvDictionary extends Extractor implements ExtractorInterface {
14 13
     use HeadersExtractorTrait;
15 14
     use CsvTrait;
16 15
 
@@ -23,8 +22,7 @@  discard block
 block discarded – undo
23 22
     /**
24 23
      * {@inheritdoc}
25 24
      */
26
-    public static function fromString($string, Translations $translations, array $options = [])
27
-    {
25
+    public static function fromString($string, Translations $translations, array $options = []) {
28 26
         $options += static::$options;
29 27
         $handle = fopen('php://memory', 'w');
30 28
 
Please login to merge, or discard this patch.
vendor/gettext/gettext/src/Extractors/JsCode.php 3 patches
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -11,64 +11,64 @@
 block discarded – undo
11 11
  */
12 12
 class JsCode extends Extractor implements ExtractorInterface, ExtractorMultiInterface
13 13
 {
14
-    public static $options = [
15
-        'constants' => [],
14
+	public static $options = [
15
+		'constants' => [],
16 16
 
17
-        'functions' => [
18
-            'gettext' => 'gettext',
19
-            '__' => 'gettext',
20
-            'ngettext' => 'ngettext',
21
-            'n__' => 'ngettext',
22
-            'pgettext' => 'pgettext',
23
-            'p__' => 'pgettext',
24
-            'dgettext' => 'dgettext',
25
-            'd__' => 'dgettext',
26
-            'dngettext' => 'dngettext',
27
-            'dn__' => 'dngettext',
28
-            'dpgettext' => 'dpgettext',
29
-            'dp__' => 'dpgettext',
30
-            'npgettext' => 'npgettext',
31
-            'np__' => 'npgettext',
32
-            'dnpgettext' => 'dnpgettext',
33
-            'dnp__' => 'dnpgettext',
34
-            'noop' => 'noop',
35
-            'noop__' => 'noop',
36
-        ],
37
-    ];
17
+		'functions' => [
18
+			'gettext' => 'gettext',
19
+			'__' => 'gettext',
20
+			'ngettext' => 'ngettext',
21
+			'n__' => 'ngettext',
22
+			'pgettext' => 'pgettext',
23
+			'p__' => 'pgettext',
24
+			'dgettext' => 'dgettext',
25
+			'd__' => 'dgettext',
26
+			'dngettext' => 'dngettext',
27
+			'dn__' => 'dngettext',
28
+			'dpgettext' => 'dpgettext',
29
+			'dp__' => 'dpgettext',
30
+			'npgettext' => 'npgettext',
31
+			'np__' => 'npgettext',
32
+			'dnpgettext' => 'dnpgettext',
33
+			'dnp__' => 'dnpgettext',
34
+			'noop' => 'noop',
35
+			'noop__' => 'noop',
36
+		],
37
+	];
38 38
 
39
-    protected static $functionsScannerClass = 'Gettext\Utils\JsFunctionsScanner';
39
+	protected static $functionsScannerClass = 'Gettext\Utils\JsFunctionsScanner';
40 40
 
41
-    /**
42
-     * @inheritdoc
43
-     * @throws Exception
44
-     */
45
-    public static function fromString($string, Translations $translations, array $options = [])
46
-    {
47
-        static::fromStringMultiple($string, [$translations], $options);
48
-    }
41
+	/**
42
+	 * @inheritdoc
43
+	 * @throws Exception
44
+	 */
45
+	public static function fromString($string, Translations $translations, array $options = [])
46
+	{
47
+		static::fromStringMultiple($string, [$translations], $options);
48
+	}
49 49
 
50
-    /**
51
-     * @inheritDoc
52
-     * @throws Exception
53
-     */
54
-    public static function fromStringMultiple($string, array $translations, array $options = [])
55
-    {
56
-        $options += static::$options;
50
+	/**
51
+	 * @inheritDoc
52
+	 * @throws Exception
53
+	 */
54
+	public static function fromStringMultiple($string, array $translations, array $options = [])
55
+	{
56
+		$options += static::$options;
57 57
 
58
-        /** @var FunctionsScanner $functions */
59
-        $functions = new static::$functionsScannerClass($string);
60
-        $functions->saveGettextFunctions($translations, $options);
61
-    }
58
+		/** @var FunctionsScanner $functions */
59
+		$functions = new static::$functionsScannerClass($string);
60
+		$functions->saveGettextFunctions($translations, $options);
61
+	}
62 62
 
63
-    /**
64
-     * @inheritDoc
65
-     * @throws Exception
66
-     */
67
-    public static function fromFileMultiple($file, array $translations, array $options = [])
68
-    {
69
-        foreach (static::getFiles($file) as $file) {
70
-            $options['file'] = $file;
71
-            static::fromStringMultiple(static::readFile($file), $translations, $options);
72
-        }
73
-    }
63
+	/**
64
+	 * @inheritDoc
65
+	 * @throws Exception
66
+	 */
67
+	public static function fromFileMultiple($file, array $translations, array $options = [])
68
+	{
69
+		foreach (static::getFiles($file) as $file) {
70
+			$options['file'] = $file;
71
+			static::fromStringMultiple(static::readFile($file), $translations, $options);
72
+		}
73
+	}
74 74
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 class JsCode extends Extractor implements ExtractorInterface, ExtractorMultiInterface
13 13
 {
14 14
     public static $options = [
15
-        'constants' => [],
15
+        'constants' => [ ],
16 16
 
17 17
         'functions' => [
18 18
             'gettext' => 'gettext',
@@ -42,33 +42,33 @@  discard block
 block discarded – undo
42 42
      * @inheritdoc
43 43
      * @throws Exception
44 44
      */
45
-    public static function fromString($string, Translations $translations, array $options = [])
45
+    public static function fromString( $string, Translations $translations, array $options = [ ] )
46 46
     {
47
-        static::fromStringMultiple($string, [$translations], $options);
47
+        static::fromStringMultiple( $string, [ $translations ], $options );
48 48
     }
49 49
 
50 50
     /**
51 51
      * @inheritDoc
52 52
      * @throws Exception
53 53
      */
54
-    public static function fromStringMultiple($string, array $translations, array $options = [])
54
+    public static function fromStringMultiple( $string, array $translations, array $options = [ ] )
55 55
     {
56 56
         $options += static::$options;
57 57
 
58 58
         /** @var FunctionsScanner $functions */
59
-        $functions = new static::$functionsScannerClass($string);
60
-        $functions->saveGettextFunctions($translations, $options);
59
+        $functions = new static::$functionsScannerClass( $string );
60
+        $functions->saveGettextFunctions( $translations, $options );
61 61
     }
62 62
 
63 63
     /**
64 64
      * @inheritDoc
65 65
      * @throws Exception
66 66
      */
67
-    public static function fromFileMultiple($file, array $translations, array $options = [])
67
+    public static function fromFileMultiple( $file, array $translations, array $options = [ ] )
68 68
     {
69
-        foreach (static::getFiles($file) as $file) {
70
-            $options['file'] = $file;
71
-            static::fromStringMultiple(static::readFile($file), $translations, $options);
69
+        foreach ( static::getFiles( $file ) as $file ) {
70
+            $options[ 'file' ] = $file;
71
+            static::fromStringMultiple( static::readFile( $file ), $translations, $options );
72 72
         }
73 73
     }
74 74
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -42,8 +42,7 @@  discard block
 block discarded – undo
42 42
      * @inheritdoc
43 43
      * @throws Exception
44 44
      */
45
-    public static function fromString($string, Translations $translations, array $options = [])
46
-    {
45
+    public static function fromString($string, Translations $translations, array $options = []) {
47 46
         static::fromStringMultiple($string, [$translations], $options);
48 47
     }
49 48
 
@@ -51,8 +50,7 @@  discard block
 block discarded – undo
51 50
      * @inheritDoc
52 51
      * @throws Exception
53 52
      */
54
-    public static function fromStringMultiple($string, array $translations, array $options = [])
55
-    {
53
+    public static function fromStringMultiple($string, array $translations, array $options = []) {
56 54
         $options += static::$options;
57 55
 
58 56
         /** @var FunctionsScanner $functions */
@@ -64,8 +62,7 @@  discard block
 block discarded – undo
64 62
      * @inheritDoc
65 63
      * @throws Exception
66 64
      */
67
-    public static function fromFileMultiple($file, array $translations, array $options = [])
68
-    {
65
+    public static function fromFileMultiple($file, array $translations, array $options = []) {
69 66
         foreach (static::getFiles($file) as $file) {
70 67
             $options['file'] = $file;
71 68
             static::fromStringMultiple(static::readFile($file), $translations, $options);
Please login to merge, or discard this patch.