We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Settings often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Settings, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 38 | class Settings implements \ArrayAccess { |
||
| 39 | |||
| 40 | /** |
||
| 41 | * The current no-break narrow space character. |
||
| 42 | * |
||
| 43 | * @var string |
||
| 44 | */ |
||
| 45 | protected $no_break_narrow_space; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Primary quote style. |
||
| 49 | * |
||
| 50 | * @var Settings\Quotes |
||
| 51 | */ |
||
| 52 | protected $primary_quote_style; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Secondary quote style. |
||
| 56 | * |
||
| 57 | * @var Settings\Quotes |
||
| 58 | */ |
||
| 59 | protected $secondary_quote_style; |
||
| 60 | |||
| 61 | /** |
||
| 62 | * A regex pattern for custom units (or the empty string). |
||
| 63 | * |
||
| 64 | * @var string |
||
| 65 | */ |
||
| 66 | protected $custom_units = ''; |
||
| 67 | |||
| 68 | /** |
||
| 69 | * A hashmap of settings for the various typographic options. |
||
| 70 | * |
||
| 71 | * @var array |
||
| 72 | */ |
||
| 73 | protected $data = []; |
||
| 74 | |||
| 75 | /** |
||
| 76 | * An array containing all self-closing HTML5 tags. |
||
| 77 | * |
||
| 78 | * @var array |
||
| 79 | */ |
||
| 80 | protected $self_closing_tags = []; |
||
| 81 | |||
| 82 | /** |
||
| 83 | * A array of tags we should never touch. |
||
| 84 | * |
||
| 85 | * @var array |
||
| 86 | */ |
||
| 87 | protected $inappropriate_tags = []; |
||
| 88 | |||
| 89 | /** |
||
| 90 | * The current dash style. |
||
| 91 | * |
||
| 92 | * @var Settings\Dashes |
||
| 93 | */ |
||
| 94 | protected $dash_style; |
||
| 95 | |||
| 96 | /** |
||
| 97 | * Sets up a new Settings object. |
||
| 98 | * |
||
| 99 | * @param bool $set_defaults If true, set default values for various properties. Defaults to true. |
||
| 100 | */ |
||
| 101 | public function __construct( $set_defaults = true ) { |
||
| 104 | |||
| 105 | /** |
||
| 106 | * Provides access to named settings (object syntax). |
||
| 107 | * |
||
| 108 | * @param string $key The settings key. |
||
| 109 | * |
||
| 110 | * @return mixed |
||
| 111 | */ |
||
| 112 | public function &__get( $key ) { |
||
| 115 | |||
| 116 | /** |
||
| 117 | * Changes a named setting (object syntax). |
||
| 118 | * |
||
| 119 | * @param string $key The settings key. |
||
| 120 | * @param mixed $value The settings value. |
||
| 121 | */ |
||
| 122 | public function __set( $key, $value ) { |
||
| 125 | |||
| 126 | /** |
||
| 127 | * Checks if a named setting exists (object syntax). |
||
| 128 | * |
||
| 129 | * @param string $key The settings key. |
||
| 130 | */ |
||
| 131 | public function __isset( $key ) { |
||
| 134 | |||
| 135 | /** |
||
| 136 | * Unsets a named setting. |
||
| 137 | * |
||
| 138 | * @param string $key The settings key. |
||
| 139 | */ |
||
| 140 | public function __unset( $key ) { |
||
| 143 | |||
| 144 | /** |
||
| 145 | * Changes a named setting (array syntax). |
||
| 146 | * |
||
| 147 | * @param string $offset The settings key. |
||
| 148 | * @param mixed $value The settings value. |
||
| 149 | */ |
||
| 150 | public function offsetSet( $offset, $value ) { |
||
| 157 | |||
| 158 | /** |
||
| 159 | * Checks if a named setting exists (array syntax). |
||
| 160 | * |
||
| 161 | * @param string $offset The settings key. |
||
| 162 | */ |
||
| 163 | public function offsetExists( $offset ) { |
||
| 166 | |||
| 167 | /** |
||
| 168 | * Unsets a named setting (array syntax). |
||
| 169 | * |
||
| 170 | * @param string $offset The settings key. |
||
| 171 | */ |
||
| 172 | public function offsetUnset( $offset ) { |
||
| 175 | |||
| 176 | /** |
||
| 177 | * Provides access to named settings (array syntax). |
||
| 178 | * |
||
| 179 | * @param string $offset The settings key. |
||
| 180 | * |
||
| 181 | * @return mixed |
||
| 182 | */ |
||
| 183 | public function offsetGet( $offset ) { |
||
| 186 | |||
| 187 | /** |
||
| 188 | * Retrieves the current non-breaking narrow space character (either the |
||
| 189 | * regular non-breaking space or the the true non-breaking narrow space  ). |
||
| 190 | * |
||
| 191 | * @return string |
||
| 192 | */ |
||
| 193 | public function no_break_narrow_space() { |
||
| 196 | |||
| 197 | /** |
||
| 198 | * Retrieves the primary (double) quote style. |
||
| 199 | * |
||
| 200 | * @return Settings\Quotes |
||
| 201 | */ |
||
| 202 | public function primary_quote_style() { |
||
| 205 | |||
| 206 | /** |
||
| 207 | * Retrieves the secondary (single) quote style. |
||
| 208 | * |
||
| 209 | * @return Settings\Quotes |
||
| 210 | */ |
||
| 211 | public function secondary_quote_style() { |
||
| 214 | |||
| 215 | /** |
||
| 216 | * Retrieves the dash style. |
||
| 217 | * |
||
| 218 | * @return Settings\Dashes |
||
| 219 | */ |
||
| 220 | public function dash_style() { |
||
| 223 | |||
| 224 | /** |
||
| 225 | * Retrieves the custom units pattern. |
||
| 226 | * |
||
| 227 | * @return string The pattern is suitable for inclusion into a regular expression. |
||
| 228 | */ |
||
| 229 | public function custom_units() { |
||
| 232 | |||
| 233 | /** |
||
| 234 | * Initialize the PHP_Typography object. |
||
| 235 | * |
||
| 236 | * @param bool $set_defaults If true, set default values for various properties. Defaults to true. |
||
| 237 | */ |
||
| 238 | private function init( $set_defaults = true ) { |
||
| 256 | |||
| 257 | /** |
||
| 258 | * (Re)set various options to their default values. |
||
| 259 | */ |
||
| 260 | public function set_defaults() { |
||
| 322 | |||
| 323 | /** |
||
| 324 | * Enable lenient parser error handling (HTML is "best guess" if enabled). |
||
| 325 | * |
||
| 326 | * @param bool $on Optional. Default false. |
||
| 327 | */ |
||
| 328 | public function set_ignore_parser_errors( $on = false ) { |
||
| 331 | |||
| 332 | /** |
||
| 333 | * Sets an optional handler for parser errors. Invalid callbacks will be silently ignored. |
||
| 334 | * |
||
| 335 | * @param callable|null $handler Optional. A callable that takes an array of error strings as its parameter. Default null. |
||
| 336 | */ |
||
| 337 | public function set_parser_errors_handler( $handler = null ) { |
||
| 344 | |||
| 345 | /** |
||
| 346 | * Enable usage of true "no-break narrow space" ( ) instead of the normal no-break space ( ). |
||
| 347 | * |
||
| 348 | * @param bool $on Optional. Default false. |
||
| 349 | */ |
||
| 350 | public function set_true_no_break_narrow_space( $on = false ) { |
||
| 358 | |||
| 359 | /** |
||
| 360 | * Sets tags for which the typography of their children will be left untouched. |
||
| 361 | * |
||
| 362 | * @param string|array $tags A comma separated list or an array of tag names. |
||
| 363 | */ |
||
| 364 | public function set_tags_to_ignore( $tags = [ 'code', 'head', 'kbd', 'object', 'option', 'pre', 'samp', 'script', 'noscript', 'noembed', 'select', 'style', 'textarea', 'title', 'var', 'math' ] ) { |
||
| 371 | |||
| 372 | /** |
||
| 373 | * Sets classes for which the typography of their children will be left untouched. |
||
| 374 | * |
||
| 375 | * @param string|array $classes A comma separated list or an array of class names. |
||
| 376 | */ |
||
| 377 | function set_classes_to_ignore( $classes = [ 'vcard', 'noTypo' ] ) { |
||
| 380 | |||
| 381 | /** |
||
| 382 | * Sets IDs for which the typography of their children will be left untouched. |
||
| 383 | * |
||
| 384 | * @param string|array $ids A comma separated list or an array of tag names. |
||
| 385 | */ |
||
| 386 | public function set_ids_to_ignore( $ids = [] ) { |
||
| 389 | |||
| 390 | /** |
||
| 391 | * Enables/disables typographic quotes. |
||
| 392 | * |
||
| 393 | * @param bool $on Optional. Default true. |
||
| 394 | */ |
||
| 395 | public function set_smart_quotes( $on = true ) { |
||
| 398 | |||
| 399 | /** |
||
| 400 | * Sets the style for primary ('double') quotemarks. |
||
| 401 | * |
||
| 402 | * Allowed values for $style: |
||
| 403 | * "doubleCurled" => "“foo”", |
||
| 404 | * "doubleCurledReversed" => "”foo”", |
||
| 405 | * "doubleLow9" => "„foo”", |
||
| 406 | * "doubleLow9Reversed" => "„foo“", |
||
| 407 | * "singleCurled" => "‘foo’", |
||
| 408 | * "singleCurledReversed" => "’foo’", |
||
| 409 | * "singleLow9" => "‚foo’", |
||
| 410 | * "singleLow9Reversed" => "‚foo‘", |
||
| 411 | * "doubleGuillemetsFrench" => "« foo »", |
||
| 412 | * "doubleGuillemets" => "«foo»", |
||
| 413 | * "doubleGuillemetsReversed" => "»foo«", |
||
| 414 | * "singleGuillemets" => "‹foo›", |
||
| 415 | * "singleGuillemetsReversed" => "›foo‹", |
||
| 416 | * "cornerBrackets" => "「foo」", |
||
| 417 | * "whiteCornerBracket" => "『foo』" |
||
| 418 | * |
||
| 419 | * @param string $style Defaults to 'doubleCurled. |
||
| 420 | */ |
||
| 421 | View Code Duplication | public function set_smart_quotes_primary( $style = Quote_Style::DOUBLE_CURLED ) { |
|
| 434 | |||
| 435 | /** |
||
| 436 | * Sets the style for secondary ('single') quotemarks. |
||
| 437 | * |
||
| 438 | * Allowed values for $style: |
||
| 439 | * "doubleCurled" => "“foo”", |
||
| 440 | * "doubleCurledReversed" => "”foo”", |
||
| 441 | * "doubleLow9" => "„foo”", |
||
| 442 | * "doubleLow9Reversed" => "„foo“", |
||
| 443 | * "singleCurled" => "‘foo’", |
||
| 444 | * "singleCurledReversed" => "’foo’", |
||
| 445 | * "singleLow9" => "‚foo’", |
||
| 446 | * "singleLow9Reversed" => "‚foo‘", |
||
| 447 | * "doubleGuillemetsFrench" => "« foo »", |
||
| 448 | * "doubleGuillemets" => "«foo»", |
||
| 449 | * "doubleGuillemetsReversed" => "»foo«", |
||
| 450 | * "singleGuillemets" => "‹foo›", |
||
| 451 | * "singleGuillemetsReversed" => "›foo‹", |
||
| 452 | * "cornerBrackets" => "「foo」", |
||
| 453 | * "whiteCornerBracket" => "『foo』" |
||
| 454 | * |
||
| 455 | * @param string $style Defaults to 'singleCurled'. |
||
| 456 | */ |
||
| 457 | View Code Duplication | public function set_smart_quotes_secondary( $style = Quote_Style::SINGLE_CURLED ) { |
|
| 470 | |||
| 471 | /** |
||
| 472 | * Enables/disables replacement of "a--a" with En Dash " -- " and "---" with Em Dash. |
||
| 473 | * |
||
| 474 | * @param bool $on Optional. Default true. |
||
| 475 | */ |
||
| 476 | public function set_smart_dashes( $on = true ) { |
||
| 479 | |||
| 480 | /** |
||
| 481 | * Sets the typographical conventions used by smart_dashes. |
||
| 482 | * |
||
| 483 | * Allowed values for $style: |
||
| 484 | * - "traditionalUS" |
||
| 485 | * - "international" |
||
| 486 | * |
||
| 487 | * @param string|Settings\Dashes $style Optional. Default Dash_Style::TRADITIONAL_US. |
||
| 488 | */ |
||
| 489 | View Code Duplication | public function set_smart_dashes_style( $style = Dash_Style::TRADITIONAL_US ) { |
|
| 502 | |||
| 503 | /** |
||
| 504 | * Enables/disables replacement of "..." with "…". |
||
| 505 | * |
||
| 506 | * @param bool $on Optional. Default true. |
||
| 507 | */ |
||
| 508 | public function set_smart_ellipses( $on = true ) { |
||
| 511 | |||
| 512 | /** |
||
| 513 | * Enables/disables replacement "creme brulee" with "crème brûlée". |
||
| 514 | * |
||
| 515 | * @param bool $on Optional. Default true. |
||
| 516 | */ |
||
| 517 | public function set_smart_diacritics( $on = true ) { |
||
| 520 | |||
| 521 | /** |
||
| 522 | * Sets the language used for diacritics replacements. |
||
| 523 | * |
||
| 524 | * @param string $lang Has to correspond to a filename in 'diacritics'. Optional. Default 'en-US'. |
||
| 525 | */ |
||
| 526 | public function set_diacritic_language( $lang = 'en-US' ) { |
||
| 543 | |||
| 544 | /** |
||
| 545 | * Sets up custom diacritics replacements. |
||
| 546 | * |
||
| 547 | * @param string|array $custom_replacements An array formatted [needle=>replacement, needle=>replacement...], |
||
| 548 | * or a string formatted `"needle"=>"replacement","needle"=>"replacement",... |
||
| 549 | */ |
||
| 550 | public function set_diacritic_custom_replacements( $custom_replacements = [] ) { |
||
| 568 | |||
| 569 | /** |
||
| 570 | * Parses a custom diacritics replacement string into an array. |
||
| 571 | * |
||
| 572 | * @param string $custom_replacements A string formatted `"needle"=>"replacement","needle"=>"replacement",... |
||
| 573 | * |
||
| 574 | * @return array |
||
| 575 | */ |
||
| 576 | private function parse_diacritics_replacement_string( $custom_replacements ) { |
||
| 592 | |||
| 593 | /** |
||
| 594 | * Update the pattern and replacement arrays in $settings['diacriticReplacement']. |
||
| 595 | * |
||
| 596 | * Should be called whenever a new diacritics replacement language is selected or |
||
| 597 | * when the custom replacements are updated. |
||
| 598 | */ |
||
| 599 | private function update_diacritics_replacement_arrays() { |
||
| 615 | |||
| 616 | /** |
||
| 617 | * Parse an array of diacritics rules. |
||
| 618 | * |
||
| 619 | * @param array $diacritics_rules The rules ( $word => $replacement ). |
||
| 620 | * @param array $patterns Resulting patterns. Passed by reference. |
||
| 621 | * @param array $replacements Resulting replacements. Passed by reference. |
||
| 622 | */ |
||
| 623 | private function parse_diacritics_rules( array $diacritics_rules, array &$patterns, array &$replacements ) { |
||
| 630 | |||
| 631 | /** |
||
| 632 | * Enables/disables replacement of (r) (c) (tm) (sm) (p) (R) (C) (TM) (SM) (P) with ® © ™ ℠ ℗. |
||
| 633 | * |
||
| 634 | * @param bool $on Optional. Default true. |
||
| 635 | */ |
||
| 636 | public function set_smart_marks( $on = true ) { |
||
| 639 | |||
| 640 | /** |
||
| 641 | * Enables/disables proper mathematical symbols. |
||
| 642 | * |
||
| 643 | * @param bool $on Optional. Default true. |
||
| 644 | */ |
||
| 645 | public function set_smart_math( $on = true ) { |
||
| 648 | |||
| 649 | /** |
||
| 650 | * Enables/disables replacement of 2^2 with 2<sup>2</sup> |
||
| 651 | * |
||
| 652 | * @param bool $on Optional. Default true. |
||
| 653 | */ |
||
| 654 | public function set_smart_exponents( $on = true ) { |
||
| 657 | |||
| 658 | /** |
||
| 659 | * Enables/disables replacement of 1/4 with <sup>1</sup>⁄<sub>4</sub>. |
||
| 660 | * |
||
| 661 | * @param bool $on Optional. Default true. |
||
| 662 | */ |
||
| 663 | public function set_smart_fractions( $on = true ) { |
||
| 666 | |||
| 667 | /** |
||
| 668 | * Enables/disables replacement of 1st with 1<sup>st</sup>. |
||
| 669 | * |
||
| 670 | * @param bool $on Optional. Default true. |
||
| 671 | */ |
||
| 672 | public function set_smart_ordinal_suffix( $on = true ) { |
||
| 675 | |||
| 676 | /** |
||
| 677 | * Enables/disables forcing single character words to next line with the insertion of . |
||
| 678 | * |
||
| 679 | * @param bool $on Optional. Default true. |
||
| 680 | */ |
||
| 681 | public function set_single_character_word_spacing( $on = true ) { |
||
| 684 | |||
| 685 | /** |
||
| 686 | * Enables/disables fraction spacing. |
||
| 687 | * |
||
| 688 | * @param bool $on Optional. Default true. |
||
| 689 | */ |
||
| 690 | public function set_fraction_spacing( $on = true ) { |
||
| 693 | |||
| 694 | /** |
||
| 695 | * Enables/disables keeping units and values together with the insertion of . |
||
| 696 | * |
||
| 697 | * @param bool $on Optional. Default true. |
||
| 698 | */ |
||
| 699 | public function set_unit_spacing( $on = true ) { |
||
| 702 | |||
| 703 | /** |
||
| 704 | * Enables/disables numbered abbreviations like "ISO 9000" together with the insertion of . |
||
| 705 | * |
||
| 706 | * @param bool $on Optional. Default true. |
||
| 707 | */ |
||
| 708 | public function set_numbered_abbreviation_spacing( $on = true ) { |
||
| 711 | |||
| 712 | /** |
||
| 713 | * Enables/disables extra whitespace before certain punction marks, as is the French custom. |
||
| 714 | * |
||
| 715 | * @param bool $on Optional. Default true. |
||
| 716 | */ |
||
| 717 | public function set_french_punctuation_spacing( $on = true ) { |
||
| 720 | |||
| 721 | /** |
||
| 722 | * Sets the list of units to keep together with their values. |
||
| 723 | * |
||
| 724 | * @param string|array $units A comma separated list or an array of units. |
||
| 725 | */ |
||
| 726 | public function set_units( $units = [] ) { |
||
| 730 | |||
| 731 | /** |
||
| 732 | * Update components and pattern for matching both standard and custom units. |
||
| 733 | * |
||
| 734 | * @param array $units An array of unit names. |
||
| 735 | */ |
||
| 736 | private function update_unit_pattern( array $units ) { |
||
| 745 | |||
| 746 | /** |
||
| 747 | * Enables/disables wrapping of Em and En dashes are in thin spaces. |
||
| 748 | * |
||
| 749 | * @param bool $on Optional. Default true. |
||
| 750 | */ |
||
| 751 | public function set_dash_spacing( $on = true ) { |
||
| 754 | |||
| 755 | /** |
||
| 756 | * Enables/disables removal of extra whitespace characters. |
||
| 757 | * |
||
| 758 | * @param bool $on Optional. Default true. |
||
| 759 | */ |
||
| 760 | public function set_space_collapse( $on = true ) { |
||
| 763 | |||
| 764 | /** |
||
| 765 | * Enables/disables widow handling. |
||
| 766 | * |
||
| 767 | * @param bool $on Optional. Default true. |
||
| 768 | */ |
||
| 769 | public function set_dewidow( $on = true ) { |
||
| 772 | |||
| 773 | /** |
||
| 774 | * Sets the maximum length of widows that will be protected. |
||
| 775 | * |
||
| 776 | * @param int $length Defaults to 5. Trying to set the value to less than 2 resets the length to the default. |
||
| 777 | */ |
||
| 778 | public function set_max_dewidow_length( $length = 5 ) { |
||
| 783 | |||
| 784 | /** |
||
| 785 | * Sets the maximum length of pulled text to keep widows company. |
||
| 786 | * |
||
| 787 | * @param int $length Defaults to 5. Trying to set the value to less than 2 resets the length to the default. |
||
| 788 | */ |
||
| 789 | public function set_max_dewidow_pull( $length = 5 ) { |
||
| 794 | |||
| 795 | /** |
||
| 796 | * Enables/disables wrapping at internal hard hyphens with the insertion of a zero-width-space. |
||
| 797 | * |
||
| 798 | * @param bool $on Optional. Default true. |
||
| 799 | */ |
||
| 800 | public function set_wrap_hard_hyphens( $on = true ) { |
||
| 803 | |||
| 804 | /** |
||
| 805 | * Enables/disables wrapping of urls. |
||
| 806 | * |
||
| 807 | * @param bool $on Optional. Default true. |
||
| 808 | */ |
||
| 809 | public function set_url_wrap( $on = true ) { |
||
| 812 | |||
| 813 | /** |
||
| 814 | * Enables/disables wrapping of email addresses. |
||
| 815 | * |
||
| 816 | * @param bool $on Optional. Default true. |
||
| 817 | */ |
||
| 818 | public function set_email_wrap( $on = true ) { |
||
| 821 | |||
| 822 | /** |
||
| 823 | * Sets the minimum character requirement after an URL wrapping point. |
||
| 824 | * |
||
| 825 | * @param int $length Defaults to 5. Trying to set the value to less than 1 resets the length to the default. |
||
| 826 | */ |
||
| 827 | public function set_min_after_url_wrap( $length = 5 ) { |
||
| 832 | |||
| 833 | /** |
||
| 834 | * Enables/disables wrapping of ampersands in <span class="amp">. |
||
| 835 | * |
||
| 836 | * @param bool $on Optional. Default true. |
||
| 837 | */ |
||
| 838 | public function set_style_ampersands( $on = true ) { |
||
| 841 | |||
| 842 | /** |
||
| 843 | * Enables/disables wrapping caps in <span class="caps">. |
||
| 844 | * |
||
| 845 | * @param bool $on Optional. Default true. |
||
| 846 | */ |
||
| 847 | public function set_style_caps( $on = true ) { |
||
| 850 | |||
| 851 | /** |
||
| 852 | * Enables/disables wrapping of initial quotes in <span class="quo"> or <span class="dquo">. |
||
| 853 | * |
||
| 854 | * @param bool $on Optional. Default true. |
||
| 855 | */ |
||
| 856 | public function set_style_initial_quotes( $on = true ) { |
||
| 859 | |||
| 860 | /** |
||
| 861 | * Enables/disables wrapping of numbers in <span class="numbers">. |
||
| 862 | * |
||
| 863 | * @param bool $on Optional. Default true. |
||
| 864 | */ |
||
| 865 | public function set_style_numbers( $on = true ) { |
||
| 868 | |||
| 869 | /** |
||
| 870 | * Enables/disables wrapping of punctiation and wide characters in <span class="pull-*">. |
||
| 871 | * |
||
| 872 | * @param bool $on Optional. Default true. |
||
| 873 | */ |
||
| 874 | public function set_style_hanging_punctuation( $on = true ) { |
||
| 877 | |||
| 878 | /** |
||
| 879 | * Sets the list of tags where initial quotes and guillemets should be styled. |
||
| 880 | * |
||
| 881 | * @param string|array $tags A comma separated list or an array of tag names. |
||
| 882 | */ |
||
| 883 | public function set_initial_quote_tags( $tags = [ 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'li', 'dd', 'dt' ] ) { |
||
| 892 | |||
| 893 | /** |
||
| 894 | * Enables/disables hyphenation. |
||
| 895 | * |
||
| 896 | * @param bool $on Optional. Default true. |
||
| 897 | */ |
||
| 898 | public function set_hyphenation( $on = true ) { |
||
| 901 | |||
| 902 | /** |
||
| 903 | * Sets the hyphenation pattern language. |
||
| 904 | * |
||
| 905 | * @param string $lang Has to correspond to a filename in 'lang'. Optional. Default 'en-US'. |
||
| 906 | */ |
||
| 907 | public function set_hyphenation_language( $lang = 'en-US' ) { |
||
| 914 | |||
| 915 | /** |
||
| 916 | * Sets the minimum length of a word that may be hyphenated. |
||
| 917 | * |
||
| 918 | * @param int $length Defaults to 5. Trying to set the value to less than 2 resets the length to the default. |
||
| 919 | */ |
||
| 920 | public function set_min_length_hyphenation( $length = 5 ) { |
||
| 925 | |||
| 926 | /** |
||
| 927 | * Sets the minimum character requirement before a hyphenation point. |
||
| 928 | * |
||
| 929 | * @param int $length Defaults to 3. Trying to set the value to less than 1 resets the length to the default. |
||
| 930 | */ |
||
| 931 | public function set_min_before_hyphenation( $length = 3 ) { |
||
| 936 | |||
| 937 | /** |
||
| 938 | * Sets the minimum character requirement after a hyphenation point. |
||
| 939 | * |
||
| 940 | * @param int $length Defaults to 2. Trying to set the value to less than 1 resets the length to the default. |
||
| 941 | */ |
||
| 942 | public function set_min_after_hyphenation( $length = 2 ) { |
||
| 947 | |||
| 948 | /** |
||
| 949 | * Enables/disables hyphenation of titles and headings. |
||
| 950 | * |
||
| 951 | * @param bool $on Optional. Default true. |
||
| 952 | */ |
||
| 953 | public function set_hyphenate_headings( $on = true ) { |
||
| 956 | |||
| 957 | /** |
||
| 958 | * Enables/disables hyphenation of words set completely in capital letters. |
||
| 959 | * |
||
| 960 | * @param bool $on Optional. Default true. |
||
| 961 | */ |
||
| 962 | public function set_hyphenate_all_caps( $on = true ) { |
||
| 965 | |||
| 966 | /** |
||
| 967 | * Enables/disables hyphenation of words starting with a capital letter. |
||
| 968 | * |
||
| 969 | * @param bool $on Optional. Default true. |
||
| 970 | */ |
||
| 971 | public function set_hyphenate_title_case( $on = true ) { |
||
| 974 | |||
| 975 | /** |
||
| 976 | * Enables/disables hyphenation of compound words (e.g. "editor-in-chief"). |
||
| 977 | * |
||
| 978 | * @param bool $on Optional. Default true. |
||
| 979 | */ |
||
| 980 | public function set_hyphenate_compounds( $on = true ) { |
||
| 983 | |||
| 984 | /** |
||
| 985 | * Sets custom word hyphenations. |
||
| 986 | * |
||
| 987 | * @param string|array $exceptions An array of words with all hyphenation points marked with a hard hyphen (or a string list of such words). |
||
| 988 | * In the latter case, only alphanumeric characters and hyphens are recognized. The default is empty. |
||
| 989 | */ |
||
| 990 | public function set_hyphenation_exceptions( $exceptions = [] ) { |
||
| 993 | |||
| 994 | /** |
||
| 995 | * Retrieves a unique hash value for the current settings. |
||
| 996 | * |
||
| 997 | * @param int $max_length The maximum number of bytes returned. Optional. Default 16. |
||
| 998 | * |
||
| 999 | * @return string A binary hash value for the current settings limited to $max_length. |
||
| 1000 | */ |
||
| 1001 | public function get_hash( $max_length = 16 ) { |
||
| 1010 | } |
||
| 1011 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.