Conditions | 117 |
Paths | 16 |
Total Lines | 104 |
Code Lines | 84 |
Lines | 0 |
Ratio | 0 % |
Tests | 63 |
CRAP Score | 308.612 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
2408 | 2 | public static function getCharDirection(string $char): string |
|
2409 | { |
||
2410 | 2 | if (self::$SUPPORT['intlChar'] === true) { |
|
2411 | 2 | $tmp_return = \IntlChar::charDirection($char); |
|
2412 | |||
2413 | // from "IntlChar"-Class |
||
2414 | 2 | $char_direction = [ |
|
2415 | 'RTL' => [1, 13, 14, 15, 21], |
||
2416 | 'LTR' => [0, 11, 12, 20], |
||
2417 | ]; |
||
2418 | |||
2419 | 2 | if (\in_array($tmp_return, $char_direction['LTR'], true)) { |
|
2420 | return 'LTR'; |
||
2421 | } |
||
2422 | |||
2423 | 2 | if (\in_array($tmp_return, $char_direction['RTL'], true)) { |
|
2424 | 2 | return 'RTL'; |
|
2425 | } |
||
2426 | } |
||
2427 | |||
2428 | 2 | $c = static::chr_to_decimal($char); |
|
2429 | |||
2430 | 2 | if (!($c >= 0x5be && $c <= 0x10b7f)) { |
|
2431 | 2 | return 'LTR'; |
|
2432 | } |
||
2433 | |||
2434 | 2 | if ($c <= 0x85e) { |
|
2435 | 2 | if ($c === 0x5be || |
|
2436 | 2 | $c === 0x5c0 || |
|
2437 | 2 | $c === 0x5c3 || |
|
2438 | 2 | $c === 0x5c6 || |
|
2439 | 2 | ($c >= 0x5d0 && $c <= 0x5ea) || |
|
2440 | 2 | ($c >= 0x5f0 && $c <= 0x5f4) || |
|
2441 | 2 | $c === 0x608 || |
|
2442 | 2 | $c === 0x60b || |
|
2443 | 2 | $c === 0x60d || |
|
2444 | 2 | $c === 0x61b || |
|
2445 | 2 | ($c >= 0x61e && $c <= 0x64a) || |
|
2446 | ($c >= 0x66d && $c <= 0x66f) || |
||
2447 | ($c >= 0x671 && $c <= 0x6d5) || |
||
2448 | ($c >= 0x6e5 && $c <= 0x6e6) || |
||
2449 | ($c >= 0x6ee && $c <= 0x6ef) || |
||
2450 | ($c >= 0x6fa && $c <= 0x70d) || |
||
2451 | $c === 0x710 || |
||
2452 | ($c >= 0x712 && $c <= 0x72f) || |
||
2453 | ($c >= 0x74d && $c <= 0x7a5) || |
||
2454 | $c === 0x7b1 || |
||
2455 | ($c >= 0x7c0 && $c <= 0x7ea) || |
||
2456 | ($c >= 0x7f4 && $c <= 0x7f5) || |
||
2457 | $c === 0x7fa || |
||
2458 | ($c >= 0x800 && $c <= 0x815) || |
||
2459 | $c === 0x81a || |
||
2460 | $c === 0x824 || |
||
2461 | $c === 0x828 || |
||
2462 | ($c >= 0x830 && $c <= 0x83e) || |
||
2463 | ($c >= 0x840 && $c <= 0x858) || |
||
2464 | 2 | $c === 0x85e |
|
2465 | ) { |
||
2466 | 2 | return 'RTL'; |
|
2467 | } |
||
2468 | 2 | } elseif ($c === 0x200f) { |
|
2469 | return 'RTL'; |
||
2470 | 2 | } elseif ($c >= 0xfb1d) { |
|
2471 | 2 | if ($c === 0xfb1d || |
|
2472 | 2 | ($c >= 0xfb1f && $c <= 0xfb28) || |
|
2473 | 2 | ($c >= 0xfb2a && $c <= 0xfb36) || |
|
2474 | 2 | ($c >= 0xfb38 && $c <= 0xfb3c) || |
|
2475 | 2 | $c === 0xfb3e || |
|
2476 | 2 | ($c >= 0xfb40 && $c <= 0xfb41) || |
|
2477 | 2 | ($c >= 0xfb43 && $c <= 0xfb44) || |
|
2478 | 2 | ($c >= 0xfb46 && $c <= 0xfbc1) || |
|
2479 | 2 | ($c >= 0xfbd3 && $c <= 0xfd3d) || |
|
2480 | 2 | ($c >= 0xfd50 && $c <= 0xfd8f) || |
|
2481 | 2 | ($c >= 0xfd92 && $c <= 0xfdc7) || |
|
2482 | 2 | ($c >= 0xfdf0 && $c <= 0xfdfc) || |
|
2483 | 2 | ($c >= 0xfe70 && $c <= 0xfe74) || |
|
2484 | 2 | ($c >= 0xfe76 && $c <= 0xfefc) || |
|
2485 | 2 | ($c >= 0x10800 && $c <= 0x10805) || |
|
2486 | 2 | $c === 0x10808 || |
|
2487 | 2 | ($c >= 0x1080a && $c <= 0x10835) || |
|
2488 | 2 | ($c >= 0x10837 && $c <= 0x10838) || |
|
2489 | 2 | $c === 0x1083c || |
|
2490 | 2 | ($c >= 0x1083f && $c <= 0x10855) || |
|
2491 | 2 | ($c >= 0x10857 && $c <= 0x1085f) || |
|
2492 | 2 | ($c >= 0x10900 && $c <= 0x1091b) || |
|
2493 | 2 | ($c >= 0x10920 && $c <= 0x10939) || |
|
2494 | 2 | $c === 0x1093f || |
|
2495 | 2 | $c === 0x10a00 || |
|
2496 | 2 | ($c >= 0x10a10 && $c <= 0x10a13) || |
|
2497 | 2 | ($c >= 0x10a15 && $c <= 0x10a17) || |
|
2498 | 2 | ($c >= 0x10a19 && $c <= 0x10a33) || |
|
2499 | 2 | ($c >= 0x10a40 && $c <= 0x10a47) || |
|
2500 | 2 | ($c >= 0x10a50 && $c <= 0x10a58) || |
|
2501 | 2 | ($c >= 0x10a60 && $c <= 0x10a7f) || |
|
2502 | 2 | ($c >= 0x10b00 && $c <= 0x10b35) || |
|
2503 | 2 | ($c >= 0x10b40 && $c <= 0x10b55) || |
|
2504 | 2 | ($c >= 0x10b58 && $c <= 0x10b72) || |
|
2505 | 2 | ($c >= 0x10b78) |
|
2506 | ) { |
||
2507 | 2 | return 'RTL'; |
|
2508 | } |
||
2509 | } |
||
2510 | |||
2511 | 2 | return 'LTR'; |
|
2512 | } |
||
13722 |