@@ -2273,38 +2273,38 @@ discard block |
||
2273 | 2273 | |
2274 | 2274 | foreach ($option as $k => $v) { |
2275 | 2275 | switch ($k) { |
2276 | - case 'encoding': |
|
2277 | - switch ($v) { |
|
2278 | - case 'utf8': |
|
2279 | - case 'ucs4_string': |
|
2280 | - case 'ucs4_array': |
|
2281 | - $this->_api_encoding = $v; |
|
2282 | - break; |
|
2276 | + case 'encoding': |
|
2277 | + switch ($v) { |
|
2278 | + case 'utf8': |
|
2279 | + case 'ucs4_string': |
|
2280 | + case 'ucs4_array': |
|
2281 | + $this->_api_encoding = $v; |
|
2282 | + break; |
|
2283 | 2283 | |
2284 | - default: |
|
2285 | - throw new InvalidArgumentException('Set Parameter: Unknown parameter ' . $v . ' for option ' . $k); |
|
2286 | - } |
|
2284 | + default: |
|
2285 | + throw new InvalidArgumentException('Set Parameter: Unknown parameter ' . $v . ' for option ' . $k); |
|
2286 | + } |
|
2287 | 2287 | |
2288 | 2288 | break; |
2289 | 2289 | |
2290 | - case 'overlong': |
|
2291 | - $this->_allow_overlong = ($v) ? true : false; |
|
2292 | - break; |
|
2290 | + case 'overlong': |
|
2291 | + $this->_allow_overlong = ($v) ? true : false; |
|
2292 | + break; |
|
2293 | 2293 | |
2294 | - case 'strict': |
|
2295 | - $this->_strict_mode = ($v) ? true : false; |
|
2296 | - break; |
|
2294 | + case 'strict': |
|
2295 | + $this->_strict_mode = ($v) ? true : false; |
|
2296 | + break; |
|
2297 | 2297 | |
2298 | - case 'version': |
|
2299 | - if (in_array($v, array('2003', '2008'))) { |
|
2300 | - $this->_version = $v; |
|
2301 | - } else { |
|
2302 | - throw new InvalidArgumentException('Set Parameter: Invalid parameter ' . $v . ' for option ' . $k); |
|
2303 | - } |
|
2304 | - break; |
|
2298 | + case 'version': |
|
2299 | + if (in_array($v, array('2003', '2008'))) { |
|
2300 | + $this->_version = $v; |
|
2301 | + } else { |
|
2302 | + throw new InvalidArgumentException('Set Parameter: Invalid parameter ' . $v . ' for option ' . $k); |
|
2303 | + } |
|
2304 | + break; |
|
2305 | 2305 | |
2306 | - default: |
|
2307 | - return false; |
|
2306 | + default: |
|
2307 | + return false; |
|
2308 | 2308 | } |
2309 | 2309 | } |
2310 | 2310 | |
@@ -2328,14 +2328,14 @@ discard block |
||
2328 | 2328 | // Forcing conversion of input to UCS4 array |
2329 | 2329 | // If one time encoding is given, use this, else the objects property |
2330 | 2330 | switch (($one_time_encoding) ? $one_time_encoding : $this->_api_encoding) { |
2331 | - case 'utf8' : $decoded = $this->_utf8_to_ucs4($decoded); |
|
2332 | - break; |
|
2333 | - case 'ucs4_string': |
|
2334 | - $decoded = $this->_ucs4_string_to_ucs4($decoded); |
|
2335 | - case 'ucs4_array': // No break; before this line. Catch case, but do nothing |
|
2336 | - break; |
|
2337 | - default: |
|
2338 | - throw new InvalidArgumentException('Unsupported input format'); |
|
2331 | + case 'utf8' : $decoded = $this->_utf8_to_ucs4($decoded); |
|
2332 | + break; |
|
2333 | + case 'ucs4_string': |
|
2334 | + $decoded = $this->_ucs4_string_to_ucs4($decoded); |
|
2335 | + case 'ucs4_array': // No break; before this line. Catch case, but do nothing |
|
2336 | + break; |
|
2337 | + default: |
|
2338 | + throw new InvalidArgumentException('Unsupported input format'); |
|
2339 | 2339 | } |
2340 | 2340 | |
2341 | 2341 | // No input, no output, what else did you expect? |
@@ -2351,35 +2351,35 @@ discard block |
||
2351 | 2351 | foreach ($decoded as $k => $v) { |
2352 | 2352 | // Make sure to use just the plain dot |
2353 | 2353 | switch ($v) { |
2354 | - case 0x3002: |
|
2355 | - case 0xFF0E: |
|
2356 | - case 0xFF61: |
|
2357 | - $decoded[$k] = 0x2E; |
|
2358 | - // It's right, no break here |
|
2359 | - // The codepoints above have to be converted to dots anyway |
|
2360 | - |
|
2361 | - // Stumbling across an anchoring character |
|
2362 | - case 0x2E: |
|
2363 | - case 0x2F: |
|
2364 | - case 0x3A: |
|
2365 | - case 0x3F: |
|
2366 | - case 0x40: |
|
2367 | - // Neither email addresses nor URLs allowed in strict mode |
|
2368 | - if ($this->_strict_mode) { |
|
2369 | - throw new InvalidArgumentException('Neither email addresses nor URLs are allowed in strict mode.'); |
|
2370 | - } |
|
2371 | - // Skip first char |
|
2372 | - if ($k) { |
|
2373 | - $encoded = ''; |
|
2374 | - $encoded = $this->_encode(array_slice($decoded, $last_begin, (($k) - $last_begin))); |
|
2375 | - if ($encoded) { |
|
2376 | - $output .= $encoded; |
|
2377 | - } else { |
|
2378 | - $output .= $this->_ucs4_to_utf8(array_slice($decoded, $last_begin, (($k) - $last_begin))); |
|
2354 | + case 0x3002: |
|
2355 | + case 0xFF0E: |
|
2356 | + case 0xFF61: |
|
2357 | + $decoded[$k] = 0x2E; |
|
2358 | + // It's right, no break here |
|
2359 | + // The codepoints above have to be converted to dots anyway |
|
2360 | + |
|
2361 | + // Stumbling across an anchoring character |
|
2362 | + case 0x2E: |
|
2363 | + case 0x2F: |
|
2364 | + case 0x3A: |
|
2365 | + case 0x3F: |
|
2366 | + case 0x40: |
|
2367 | + // Neither email addresses nor URLs allowed in strict mode |
|
2368 | + if ($this->_strict_mode) { |
|
2369 | + throw new InvalidArgumentException('Neither email addresses nor URLs are allowed in strict mode.'); |
|
2379 | 2370 | } |
2380 | - $output .= chr($decoded[$k]); |
|
2381 | - } |
|
2382 | - $last_begin = $k + 1; |
|
2371 | + // Skip first char |
|
2372 | + if ($k) { |
|
2373 | + $encoded = ''; |
|
2374 | + $encoded = $this->_encode(array_slice($decoded, $last_begin, (($k) - $last_begin))); |
|
2375 | + if ($encoded) { |
|
2376 | + $output .= $encoded; |
|
2377 | + } else { |
|
2378 | + $output .= $this->_ucs4_to_utf8(array_slice($decoded, $last_begin, (($k) - $last_begin))); |
|
2379 | + } |
|
2380 | + $output .= chr($decoded[$k]); |
|
2381 | + } |
|
2382 | + $last_begin = $k + 1; |
|
2383 | 2383 | } |
2384 | 2384 | } |
2385 | 2385 | // Catch the rest of the string |
@@ -2417,12 +2417,12 @@ discard block |
||
2417 | 2417 | // Optionally set |
2418 | 2418 | if ($one_time_encoding) { |
2419 | 2419 | switch ($one_time_encoding) { |
2420 | - case 'utf8': |
|
2421 | - case 'ucs4_string': |
|
2422 | - case 'ucs4_array': |
|
2423 | - break; |
|
2424 | - default: |
|
2425 | - throw new InvalidArgumentException('Unknown encoding ' . $one_time_encoding); |
|
2420 | + case 'utf8': |
|
2421 | + case 'ucs4_string': |
|
2422 | + case 'ucs4_array': |
|
2423 | + break; |
|
2424 | + default: |
|
2425 | + throw new InvalidArgumentException('Unknown encoding ' . $one_time_encoding); |
|
2426 | 2426 | } |
2427 | 2427 | } |
2428 | 2428 | // Make sure to drop any newline characters around |
@@ -2480,16 +2480,16 @@ discard block |
||
2480 | 2480 | // The output is UTF-8 by default, other output formats need conversion here |
2481 | 2481 | // If one time encoding is given, use this, else the objects property |
2482 | 2482 | switch (($one_time_encoding) ? $one_time_encoding : $this->_api_encoding) { |
2483 | - case 'utf8' : return $return; |
|
2484 | - break; |
|
2485 | - case 'ucs4_string': |
|
2486 | - return $this->_ucs4_to_ucs4_string($this->_utf8_to_ucs4($return)); |
|
2487 | - break; |
|
2488 | - case 'ucs4_array': |
|
2489 | - return $this->_utf8_to_ucs4($return); |
|
2490 | - break; |
|
2491 | - default: |
|
2492 | - throw new InvalidArgumentException('Unsupported output format'); |
|
2483 | + case 'utf8' : return $return; |
|
2484 | + break; |
|
2485 | + case 'ucs4_string': |
|
2486 | + return $this->_ucs4_to_ucs4_string($this->_utf8_to_ucs4($return)); |
|
2487 | + break; |
|
2488 | + case 'ucs4_array': |
|
2489 | + return $this->_utf8_to_ucs4($return); |
|
2490 | + break; |
|
2491 | + default: |
|
2492 | + throw new InvalidArgumentException('Unsupported output format'); |
|
2493 | 2493 | } |
2494 | 2494 | } |
2495 | 2495 |