We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
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 |
||
| 40 | class Settings implements \ArrayAccess, \JsonSerializable { |
||
| 41 | |||
| 42 | /** |
||
| 43 | * The current no-break narrow space character. |
||
| 44 | * |
||
| 45 | * @var string |
||
| 46 | */ |
||
| 47 | protected $no_break_narrow_space; |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Primary quote style. |
||
| 51 | * |
||
| 52 | * @var Settings\Quotes |
||
| 53 | */ |
||
| 54 | protected $primary_quote_style; |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Secondary quote style. |
||
| 58 | * |
||
| 59 | * @var Settings\Quotes |
||
| 60 | */ |
||
| 61 | protected $secondary_quote_style; |
||
| 62 | |||
| 63 | /** |
||
| 64 | * A regex pattern for custom units (or the empty string). |
||
| 65 | * |
||
| 66 | * @var string |
||
| 67 | */ |
||
| 68 | protected $custom_units = ''; |
||
| 69 | |||
| 70 | /** |
||
| 71 | * A hashmap of settings for the various typographic options. |
||
| 72 | * |
||
| 73 | * @var array |
||
| 74 | */ |
||
| 75 | protected $data = []; |
||
| 76 | |||
| 77 | /** |
||
| 78 | * The current dash style. |
||
| 79 | * |
||
| 80 | * @var Settings\Dashes |
||
| 81 | */ |
||
| 82 | protected $dash_style; |
||
| 83 | |||
| 84 | /** |
||
| 85 | * Sets up a new Settings object. |
||
| 86 | * |
||
| 87 | * @param bool $set_defaults If true, set default values for various properties. Defaults to true. |
||
| 88 | */ |
||
| 89 | public function __construct( $set_defaults = true ) { |
||
| 92 | |||
| 93 | /** |
||
| 94 | * Provides access to named settings (object syntax). |
||
| 95 | * |
||
| 96 | * @param string $key The settings key. |
||
| 97 | * |
||
| 98 | * @return mixed |
||
| 99 | */ |
||
| 100 | public function &__get( $key ) { |
||
| 103 | |||
| 104 | /** |
||
| 105 | * Changes a named setting (object syntax). |
||
| 106 | * |
||
| 107 | * @param string $key The settings key. |
||
| 108 | * @param mixed $value The settings value. |
||
| 109 | */ |
||
| 110 | public function __set( $key, $value ) { |
||
| 113 | |||
| 114 | /** |
||
| 115 | * Checks if a named setting exists (object syntax). |
||
| 116 | * |
||
| 117 | * @param string $key The settings key. |
||
| 118 | */ |
||
| 119 | public function __isset( $key ) { |
||
| 122 | |||
| 123 | /** |
||
| 124 | * Unsets a named setting. |
||
| 125 | * |
||
| 126 | * @param string $key The settings key. |
||
| 127 | */ |
||
| 128 | public function __unset( $key ) { |
||
| 131 | |||
| 132 | /** |
||
| 133 | * Changes a named setting (array syntax). |
||
| 134 | * |
||
| 135 | * @param string $offset The settings key. |
||
| 136 | * @param mixed $value The settings value. |
||
| 137 | */ |
||
| 138 | public function offsetSet( $offset, $value ) { |
||
| 143 | |||
| 144 | /** |
||
| 145 | * Checks if a named setting exists (array syntax). |
||
| 146 | * |
||
| 147 | * @param string $offset The settings key. |
||
| 148 | */ |
||
| 149 | public function offsetExists( $offset ) { |
||
| 152 | |||
| 153 | /** |
||
| 154 | * Unsets a named setting (array syntax). |
||
| 155 | * |
||
| 156 | * @param string $offset The settings key. |
||
| 157 | */ |
||
| 158 | public function offsetUnset( $offset ) { |
||
| 161 | |||
| 162 | /** |
||
| 163 | * Provides access to named settings (array syntax). |
||
| 164 | * |
||
| 165 | * @param string $offset The settings key. |
||
| 166 | * |
||
| 167 | * @return mixed |
||
| 168 | */ |
||
| 169 | public function offsetGet( $offset ) { |
||
| 172 | |||
| 173 | /** |
||
| 174 | * Provides a JSON serialization of the settings. |
||
| 175 | * |
||
| 176 | * @return mixed |
||
| 177 | */ |
||
| 178 | public function jsonSerialize() { |
||
| 190 | |||
| 191 | /** |
||
| 192 | * Retrieves the current non-breaking narrow space character (either the |
||
| 193 | * regular non-breaking space or the the true non-breaking narrow space  ). |
||
| 194 | * |
||
| 195 | * @return string |
||
| 196 | */ |
||
| 197 | public function no_break_narrow_space() { |
||
| 200 | |||
| 201 | /** |
||
| 202 | * Retrieves the primary (double) quote style. |
||
| 203 | * |
||
| 204 | * @return Settings\Quotes |
||
| 205 | */ |
||
| 206 | public function primary_quote_style() { |
||
| 209 | |||
| 210 | /** |
||
| 211 | * Retrieves the secondary (single) quote style. |
||
| 212 | * |
||
| 213 | * @return Settings\Quotes |
||
| 214 | */ |
||
| 215 | public function secondary_quote_style() { |
||
| 218 | |||
| 219 | /** |
||
| 220 | * Retrieves the dash style. |
||
| 221 | * |
||
| 222 | * @return Settings\Dashes |
||
| 223 | */ |
||
| 224 | public function dash_style() { |
||
| 227 | |||
| 228 | /** |
||
| 229 | * Retrieves the custom units pattern. |
||
| 230 | * |
||
| 231 | * @return string The pattern is suitable for inclusion into a regular expression. |
||
| 232 | */ |
||
| 233 | public function custom_units() { |
||
| 236 | |||
| 237 | /** |
||
| 238 | * Initialize the PHP_Typography object. |
||
| 239 | * |
||
| 240 | * @param bool $set_defaults If true, set default values for various properties. Defaults to true. |
||
| 241 | */ |
||
| 242 | private function init( $set_defaults = true ) { |
||
| 254 | |||
| 255 | /** |
||
| 256 | * (Re)set various options to their default values. |
||
| 257 | */ |
||
| 258 | public function set_defaults() { |
||
| 321 | |||
| 322 | /** |
||
| 323 | * Enable lenient parser error handling (HTML is "best guess" if enabled). |
||
| 324 | * |
||
| 325 | * @param bool $on Optional. Default false. |
||
| 326 | */ |
||
| 327 | public function set_ignore_parser_errors( $on = false ) { |
||
| 330 | |||
| 331 | /** |
||
| 332 | * Sets an optional handler for parser errors. Invalid callbacks will be silently ignored. |
||
| 333 | * |
||
| 334 | * @since 6.0.0. callable type is enforced via typehinting. |
||
| 335 | * |
||
| 336 | * @param callable|null $handler Optional. A callable that takes an array of error strings as its parameter. Default null. |
||
| 337 | */ |
||
| 338 | public function set_parser_errors_handler( callable $handler = null ) { |
||
| 341 | |||
| 342 | /** |
||
| 343 | * Enable usage of true "no-break narrow space" ( ) instead of the normal no-break space ( ). |
||
| 344 | * |
||
| 345 | * @param bool $on Optional. Default false. |
||
| 346 | */ |
||
| 347 | public function set_true_no_break_narrow_space( $on = false ) { |
||
| 355 | |||
| 356 | /** |
||
| 357 | * Sets tags for which the typography of their children will be left untouched. |
||
| 358 | * |
||
| 359 | * @param string|array $tags A comma separated list or an array of tag names. |
||
| 360 | */ |
||
| 361 | public function set_tags_to_ignore( $tags = [ 'code', 'head', 'kbd', 'object', 'option', 'pre', 'samp', 'script', 'noscript', 'noembed', 'select', 'style', 'textarea', 'title', 'var', 'math' ] ) { |
||
| 367 | |||
| 368 | /** |
||
| 369 | * Sets classes for which the typography of their children will be left untouched. |
||
| 370 | * |
||
| 371 | * @param string|array $classes A comma separated list or an array of class names. |
||
| 372 | */ |
||
| 373 | public function set_classes_to_ignore( $classes = [ 'vcard', 'noTypo' ] ) { |
||
| 376 | |||
| 377 | /** |
||
| 378 | * Sets IDs for which the typography of their children will be left untouched. |
||
| 379 | * |
||
| 380 | * @param string|array $ids A comma separated list or an array of tag names. |
||
| 381 | */ |
||
| 382 | public function set_ids_to_ignore( $ids = [] ) { |
||
| 385 | |||
| 386 | /** |
||
| 387 | * Enables/disables typographic quotes. |
||
| 388 | * |
||
| 389 | * @param bool $on Optional. Default true. |
||
| 390 | */ |
||
| 391 | public function set_smart_quotes( $on = true ) { |
||
| 394 | |||
| 395 | /** |
||
| 396 | * Sets the style for primary ('double') quotemarks. |
||
| 397 | * |
||
| 398 | * Allowed values for $style: |
||
| 399 | * "doubleCurled" => "“foo”", |
||
| 400 | * "doubleCurledReversed" => "”foo”", |
||
| 401 | * "doubleLow9" => "„foo”", |
||
| 402 | * "doubleLow9Reversed" => "„foo“", |
||
| 403 | * "singleCurled" => "‘foo’", |
||
| 404 | * "singleCurledReversed" => "’foo’", |
||
| 405 | * "singleLow9" => "‚foo’", |
||
| 406 | * "singleLow9Reversed" => "‚foo‘", |
||
| 407 | * "doubleGuillemetsFrench" => "« foo »", |
||
| 408 | * "doubleGuillemets" => "«foo»", |
||
| 409 | * "doubleGuillemetsReversed" => "»foo«", |
||
| 410 | * "singleGuillemets" => "‹foo›", |
||
| 411 | * "singleGuillemetsReversed" => "›foo‹", |
||
| 412 | * "cornerBrackets" => "「foo」", |
||
| 413 | * "whiteCornerBracket" => "『foo』" |
||
| 414 | * |
||
| 415 | * @param string $style Defaults to 'doubleCurled. |
||
| 416 | * |
||
| 417 | * @throws \DomainException Thrown if $style constant is invalid. |
||
| 418 | */ |
||
| 419 | public function set_smart_quotes_primary( $style = Quote_Style::DOUBLE_CURLED ) { |
||
| 422 | |||
| 423 | /** |
||
| 424 | * Sets the style for secondary ('single') quotemarks. |
||
| 425 | * |
||
| 426 | * Allowed values for $style: |
||
| 427 | * "doubleCurled" => "“foo”", |
||
| 428 | * "doubleCurledReversed" => "”foo”", |
||
| 429 | * "doubleLow9" => "„foo”", |
||
| 430 | * "doubleLow9Reversed" => "„foo“", |
||
| 431 | * "singleCurled" => "‘foo’", |
||
| 432 | * "singleCurledReversed" => "’foo’", |
||
| 433 | * "singleLow9" => "‚foo’", |
||
| 434 | * "singleLow9Reversed" => "‚foo‘", |
||
| 435 | * "doubleGuillemetsFrench" => "« foo »", |
||
| 436 | * "doubleGuillemets" => "«foo»", |
||
| 437 | * "doubleGuillemetsReversed" => "»foo«", |
||
| 438 | * "singleGuillemets" => "‹foo›", |
||
| 439 | * "singleGuillemetsReversed" => "›foo‹", |
||
| 440 | * "cornerBrackets" => "「foo」", |
||
| 441 | * "whiteCornerBracket" => "『foo』" |
||
| 442 | * |
||
| 443 | * @param string $style Defaults to 'singleCurled'. |
||
| 444 | * |
||
| 445 | * @throws \DomainException Thrown if $style constant is invalid. |
||
| 446 | */ |
||
| 447 | public function set_smart_quotes_secondary( $style = Quote_Style::SINGLE_CURLED ) { |
||
| 450 | |||
| 451 | /** |
||
| 452 | * Retrieves a Quotes instance from a given style. |
||
| 453 | * |
||
| 454 | * @param Settings\Quotes|string $style A Quotes instance or a quote style constant. |
||
| 455 | * |
||
| 456 | * @throws \DomainException Thrown if $style constant is invalid. |
||
| 457 | * |
||
| 458 | * @return Settings\Quotes |
||
| 459 | */ |
||
| 460 | protected function get_quote_style( $style ) { |
||
| 463 | |||
| 464 | /** |
||
| 465 | * Retrieves a Quotes instance from a given style. |
||
| 466 | * |
||
| 467 | * @since 6.0.0 |
||
| 468 | * |
||
| 469 | * @param Settings\Dashes|string $style A Dashes instance or a dash style constant. |
||
| 470 | * |
||
| 471 | * @throws \DomainException Thrown if $style constant is invalid. |
||
| 472 | * |
||
| 473 | * @return Settings\Dashes |
||
| 474 | */ |
||
| 475 | protected function get_dash_style( $style ) { |
||
| 478 | |||
| 479 | /** |
||
| 480 | * Retrieves an object from a given style. |
||
| 481 | * |
||
| 482 | * @param object|string $style A style object instance or a style constant. |
||
| 483 | * @param string $expected_class A class name. |
||
| 484 | * @param callable $get_style A function that returns a style object from a given style constant. |
||
| 485 | * @param string $description Style description for the exception message. |
||
| 486 | * |
||
| 487 | * @throws \DomainException Thrown if $style constant is invalid. |
||
| 488 | * |
||
| 489 | * @return mixed An instance of $expected_class. |
||
| 490 | */ |
||
| 491 | protected function get_style( $style, $expected_class, callable $get_style, $description ) { |
||
| 504 | |||
| 505 | /** |
||
| 506 | * Enables/disables replacement of "a--a" with En Dash " -- " and "---" with Em Dash. |
||
| 507 | * |
||
| 508 | * @param bool $on Optional. Default true. |
||
| 509 | */ |
||
| 510 | public function set_smart_dashes( $on = true ) { |
||
| 513 | |||
| 514 | /** |
||
| 515 | * Sets the typographical conventions used by smart_dashes. |
||
| 516 | * |
||
| 517 | * Allowed values for $style: |
||
| 518 | * - "traditionalUS" |
||
| 519 | * - "international" |
||
| 520 | * |
||
| 521 | * @param string|Settings\Dashes $style Optional. Default Dash_Style::TRADITIONAL_US. |
||
| 522 | * |
||
| 523 | * @throws \DomainException Thrown if $style constant is invalid. |
||
| 524 | */ |
||
| 525 | public function set_smart_dashes_style( $style = Dash_Style::TRADITIONAL_US ) { |
||
| 528 | |||
| 529 | /** |
||
| 530 | * Enables/disables replacement of "..." with "…". |
||
| 531 | * |
||
| 532 | * @param bool $on Optional. Default true. |
||
| 533 | */ |
||
| 534 | public function set_smart_ellipses( $on = true ) { |
||
| 537 | |||
| 538 | /** |
||
| 539 | * Enables/disables replacement "creme brulee" with "crème brûlée". |
||
| 540 | * |
||
| 541 | * @param bool $on Optional. Default true. |
||
| 542 | */ |
||
| 543 | public function set_smart_diacritics( $on = true ) { |
||
| 546 | |||
| 547 | /** |
||
| 548 | * Sets the language used for diacritics replacements. |
||
| 549 | * |
||
| 550 | * @param string $lang Has to correspond to a filename in 'diacritics'. Optional. Default 'en-US'. |
||
| 551 | */ |
||
| 552 | public function set_diacritic_language( $lang = 'en-US' ) { |
||
| 569 | |||
| 570 | /** |
||
| 571 | * Sets up custom diacritics replacements. |
||
| 572 | * |
||
| 573 | * @param string|array $custom_replacements An array formatted [needle=>replacement, needle=>replacement...], |
||
| 574 | * or a string formatted `"needle"=>"replacement","needle"=>"replacement",... |
||
| 575 | */ |
||
| 576 | public function set_diacritic_custom_replacements( $custom_replacements = [] ) { |
||
| 594 | |||
| 595 | /** |
||
| 596 | * Parses a custom diacritics replacement string into an array. |
||
| 597 | * |
||
| 598 | * @param string $custom_replacements A string formatted `"needle"=>"replacement","needle"=>"replacement",... |
||
| 599 | * |
||
| 600 | * @return array |
||
| 601 | */ |
||
| 602 | private function parse_diacritics_replacement_string( $custom_replacements ) { |
||
| 618 | |||
| 619 | /** |
||
| 620 | * Provides an array_map implementation with control over resulting array's keys. |
||
| 621 | * |
||
| 622 | * Based on https://gist.github.com/jasand-pereza/84ecec7907f003564584. |
||
| 623 | * |
||
| 624 | * @since 6.0.0 |
||
| 625 | * |
||
| 626 | * @param callable $callback A callback function that needs to return [ $key => $value ] pairs. |
||
| 627 | * @param array $array The array. |
||
| 628 | * |
||
| 629 | * @return array |
||
| 630 | */ |
||
| 631 | protected static function array_map_assoc( callable $callback, array $array ) { |
||
| 644 | |||
| 645 | /** |
||
| 646 | * Update the pattern and replacement arrays in $settings['diacriticReplacement']. |
||
| 647 | * |
||
| 648 | * Should be called whenever a new diacritics replacement language is selected or |
||
| 649 | * when the custom replacements are updated. |
||
| 650 | */ |
||
| 651 | private function update_diacritics_replacement_arrays() { |
||
| 667 | |||
| 668 | /** |
||
| 669 | * Parse an array of diacritics rules. |
||
| 670 | * |
||
| 671 | * @param array $diacritics_rules The rules ( $word => $replacement ). |
||
| 672 | * @param array $patterns Resulting patterns. Passed by reference. |
||
| 673 | * @param array $replacements Resulting replacements. Passed by reference. |
||
| 674 | */ |
||
| 675 | private function parse_diacritics_rules( array $diacritics_rules, array &$patterns, array &$replacements ) { |
||
| 682 | |||
| 683 | /** |
||
| 684 | * Enables/disables replacement of (r) (c) (tm) (sm) (p) (R) (C) (TM) (SM) (P) with ® © ™ ℠ ℗. |
||
| 685 | * |
||
| 686 | * @param bool $on Optional. Default true. |
||
| 687 | */ |
||
| 688 | public function set_smart_marks( $on = true ) { |
||
| 691 | |||
| 692 | /** |
||
| 693 | * Enables/disables proper mathematical symbols. |
||
| 694 | * |
||
| 695 | * @param bool $on Optional. Default true. |
||
| 696 | */ |
||
| 697 | public function set_smart_math( $on = true ) { |
||
| 700 | |||
| 701 | /** |
||
| 702 | * Enables/disables replacement of 2^2 with 2<sup>2</sup> |
||
| 703 | * |
||
| 704 | * @param bool $on Optional. Default true. |
||
| 705 | */ |
||
| 706 | public function set_smart_exponents( $on = true ) { |
||
| 709 | |||
| 710 | /** |
||
| 711 | * Enables/disables replacement of 1/4 with <sup>1</sup>⁄<sub>4</sub>. |
||
| 712 | * |
||
| 713 | * @param bool $on Optional. Default true. |
||
| 714 | */ |
||
| 715 | public function set_smart_fractions( $on = true ) { |
||
| 718 | |||
| 719 | /** |
||
| 720 | * Enables/disables replacement of 1st with 1<sup>st</sup>. |
||
| 721 | * |
||
| 722 | * @param bool $on Optional. Default true. |
||
| 723 | */ |
||
| 724 | public function set_smart_ordinal_suffix( $on = true ) { |
||
| 727 | |||
| 728 | /** |
||
| 729 | * Enables/disables forcing single character words to next line with the insertion of . |
||
| 730 | * |
||
| 731 | * @param bool $on Optional. Default true. |
||
| 732 | */ |
||
| 733 | public function set_single_character_word_spacing( $on = true ) { |
||
| 736 | |||
| 737 | /** |
||
| 738 | * Enables/disables fraction spacing. |
||
| 739 | * |
||
| 740 | * @param bool $on Optional. Default true. |
||
| 741 | */ |
||
| 742 | public function set_fraction_spacing( $on = true ) { |
||
| 745 | |||
| 746 | /** |
||
| 747 | * Enables/disables keeping units and values together with the insertion of . |
||
| 748 | * |
||
| 749 | * @param bool $on Optional. Default true. |
||
| 750 | */ |
||
| 751 | public function set_unit_spacing( $on = true ) { |
||
| 754 | |||
| 755 | /** |
||
| 756 | * Enables/disables numbered abbreviations like "ISO 9000" together with the insertion of . |
||
| 757 | * |
||
| 758 | * @param bool $on Optional. Default true. |
||
| 759 | */ |
||
| 760 | public function set_numbered_abbreviation_spacing( $on = true ) { |
||
| 763 | |||
| 764 | /** |
||
| 765 | * Enables/disables extra whitespace before certain punction marks, as is the French custom. |
||
| 766 | * |
||
| 767 | * @param bool $on Optional. Default true. |
||
| 768 | */ |
||
| 769 | public function set_french_punctuation_spacing( $on = true ) { |
||
| 772 | |||
| 773 | /** |
||
| 774 | * Sets the list of units to keep together with their values. |
||
| 775 | * |
||
| 776 | * @param string|array $units A comma separated list or an array of units. |
||
| 777 | */ |
||
| 778 | public function set_units( $units = [] ) { |
||
| 782 | |||
| 783 | /** |
||
| 784 | * Update components and pattern for matching both standard and custom units. |
||
| 785 | * |
||
| 786 | * @param array $units An array of unit names. |
||
| 787 | */ |
||
| 788 | private function update_unit_pattern( array $units ) { |
||
| 797 | |||
| 798 | /** |
||
| 799 | * Enables/disables wrapping of Em and En dashes are in thin spaces. |
||
| 800 | * |
||
| 801 | * @param bool $on Optional. Default true. |
||
| 802 | */ |
||
| 803 | public function set_dash_spacing( $on = true ) { |
||
| 806 | |||
| 807 | /** |
||
| 808 | * Enables/disables removal of extra whitespace characters. |
||
| 809 | * |
||
| 810 | * @param bool $on Optional. Default true. |
||
| 811 | */ |
||
| 812 | public function set_space_collapse( $on = true ) { |
||
| 815 | |||
| 816 | /** |
||
| 817 | * Enables/disables widow handling. |
||
| 818 | * |
||
| 819 | * @param bool $on Optional. Default true. |
||
| 820 | */ |
||
| 821 | public function set_dewidow( $on = true ) { |
||
| 824 | |||
| 825 | /** |
||
| 826 | * Sets the maximum length of widows that will be protected. |
||
| 827 | * |
||
| 828 | * @param int $length Defaults to 5. Trying to set the value to less than 2 resets the length to the default. |
||
| 829 | */ |
||
| 830 | public function set_max_dewidow_length( $length = 5 ) { |
||
| 835 | |||
| 836 | /** |
||
| 837 | * Sets the maximum number of words considered for dewidowing. |
||
| 838 | * |
||
| 839 | * @param int $number Defaults to 1. Only 1, 2 and 3 are valid. |
||
| 840 | */ |
||
| 841 | public function set_dewidow_word_number( $number = 1 ) { |
||
| 846 | |||
| 847 | /** |
||
| 848 | * Sets the maximum length of pulled text to keep widows company. |
||
| 849 | * |
||
| 850 | * @param int $length Defaults to 5. Trying to set the value to less than 2 resets the length to the default. |
||
| 851 | */ |
||
| 852 | public function set_max_dewidow_pull( $length = 5 ) { |
||
| 857 | |||
| 858 | /** |
||
| 859 | * Enables/disables wrapping at internal hard hyphens with the insertion of a zero-width-space. |
||
| 860 | * |
||
| 861 | * @param bool $on Optional. Default true. |
||
| 862 | */ |
||
| 863 | public function set_wrap_hard_hyphens( $on = true ) { |
||
| 866 | |||
| 867 | /** |
||
| 868 | * Enables/disables wrapping of urls. |
||
| 869 | * |
||
| 870 | * @param bool $on Optional. Default true. |
||
| 871 | */ |
||
| 872 | public function set_url_wrap( $on = true ) { |
||
| 875 | |||
| 876 | /** |
||
| 877 | * Enables/disables wrapping of email addresses. |
||
| 878 | * |
||
| 879 | * @param bool $on Optional. Default true. |
||
| 880 | */ |
||
| 881 | public function set_email_wrap( $on = true ) { |
||
| 884 | |||
| 885 | /** |
||
| 886 | * Sets the minimum character requirement after an URL wrapping point. |
||
| 887 | * |
||
| 888 | * @param int $length Defaults to 5. Trying to set the value to less than 1 resets the length to the default. |
||
| 889 | */ |
||
| 890 | public function set_min_after_url_wrap( $length = 5 ) { |
||
| 895 | |||
| 896 | /** |
||
| 897 | * Enables/disables wrapping of ampersands in <span class="amp">. |
||
| 898 | * |
||
| 899 | * @param bool $on Optional. Default true. |
||
| 900 | */ |
||
| 901 | public function set_style_ampersands( $on = true ) { |
||
| 904 | |||
| 905 | /** |
||
| 906 | * Enables/disables wrapping caps in <span class="caps">. |
||
| 907 | * |
||
| 908 | * @param bool $on Optional. Default true. |
||
| 909 | */ |
||
| 910 | public function set_style_caps( $on = true ) { |
||
| 913 | |||
| 914 | /** |
||
| 915 | * Enables/disables wrapping of initial quotes in <span class="quo"> or <span class="dquo">. |
||
| 916 | * |
||
| 917 | * @param bool $on Optional. Default true. |
||
| 918 | */ |
||
| 919 | public function set_style_initial_quotes( $on = true ) { |
||
| 922 | |||
| 923 | /** |
||
| 924 | * Enables/disables wrapping of numbers in <span class="numbers">. |
||
| 925 | * |
||
| 926 | * @param bool $on Optional. Default true. |
||
| 927 | */ |
||
| 928 | public function set_style_numbers( $on = true ) { |
||
| 931 | |||
| 932 | /** |
||
| 933 | * Enables/disables wrapping of punctiation and wide characters in <span class="pull-*">. |
||
| 934 | * |
||
| 935 | * @param bool $on Optional. Default true. |
||
| 936 | */ |
||
| 937 | public function set_style_hanging_punctuation( $on = true ) { |
||
| 940 | |||
| 941 | /** |
||
| 942 | * Sets the list of tags where initial quotes and guillemets should be styled. |
||
| 943 | * |
||
| 944 | * @param string|array $tags A comma separated list or an array of tag names. |
||
| 945 | */ |
||
| 946 | public function set_initial_quote_tags( $tags = [ 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'li', 'dd', 'dt' ] ) { |
||
| 955 | |||
| 956 | /** |
||
| 957 | * Enables/disables hyphenation. |
||
| 958 | * |
||
| 959 | * @param bool $on Optional. Default true. |
||
| 960 | */ |
||
| 961 | public function set_hyphenation( $on = true ) { |
||
| 964 | |||
| 965 | /** |
||
| 966 | * Sets the hyphenation pattern language. |
||
| 967 | * |
||
| 968 | * @param string $lang Has to correspond to a filename in 'lang'. Optional. Default 'en-US'. |
||
| 969 | */ |
||
| 970 | public function set_hyphenation_language( $lang = 'en-US' ) { |
||
| 977 | |||
| 978 | /** |
||
| 979 | * Sets the minimum length of a word that may be hyphenated. |
||
| 980 | * |
||
| 981 | * @param int $length Defaults to 5. Trying to set the value to less than 2 resets the length to the default. |
||
| 982 | */ |
||
| 983 | public function set_min_length_hyphenation( $length = 5 ) { |
||
| 988 | |||
| 989 | /** |
||
| 990 | * Sets the minimum character requirement before a hyphenation point. |
||
| 991 | * |
||
| 992 | * @param int $length Defaults to 3. Trying to set the value to less than 1 resets the length to the default. |
||
| 993 | */ |
||
| 994 | public function set_min_before_hyphenation( $length = 3 ) { |
||
| 999 | |||
| 1000 | /** |
||
| 1001 | * Sets the minimum character requirement after a hyphenation point. |
||
| 1002 | * |
||
| 1003 | * @param int $length Defaults to 2. Trying to set the value to less than 1 resets the length to the default. |
||
| 1004 | */ |
||
| 1005 | public function set_min_after_hyphenation( $length = 2 ) { |
||
| 1010 | |||
| 1011 | /** |
||
| 1012 | * Enables/disables hyphenation of titles and headings. |
||
| 1013 | * |
||
| 1014 | * @param bool $on Optional. Default true. |
||
| 1015 | */ |
||
| 1016 | public function set_hyphenate_headings( $on = true ) { |
||
| 1019 | |||
| 1020 | /** |
||
| 1021 | * Enables/disables hyphenation of words set completely in capital letters. |
||
| 1022 | * |
||
| 1023 | * @param bool $on Optional. Default true. |
||
| 1024 | */ |
||
| 1025 | public function set_hyphenate_all_caps( $on = true ) { |
||
| 1028 | |||
| 1029 | /** |
||
| 1030 | * Enables/disables hyphenation of words starting with a capital letter. |
||
| 1031 | * |
||
| 1032 | * @param bool $on Optional. Default true. |
||
| 1033 | */ |
||
| 1034 | public function set_hyphenate_title_case( $on = true ) { |
||
| 1037 | |||
| 1038 | /** |
||
| 1039 | * Enables/disables hyphenation of compound words (e.g. "editor-in-chief"). |
||
| 1040 | * |
||
| 1041 | * @param bool $on Optional. Default true. |
||
| 1042 | */ |
||
| 1043 | public function set_hyphenate_compounds( $on = true ) { |
||
| 1046 | |||
| 1047 | /** |
||
| 1048 | * Sets custom word hyphenations. |
||
| 1049 | * |
||
| 1050 | * @param string|array $exceptions An array of words with all hyphenation points marked with a hard hyphen (or a string list of such words). |
||
| 1051 | * In the latter case, only alphanumeric characters and hyphens are recognized. The default is empty. |
||
| 1052 | */ |
||
| 1053 | public function set_hyphenation_exceptions( $exceptions = [] ) { |
||
| 1056 | |||
| 1057 | /** |
||
| 1058 | * Retrieves a unique hash value for the current settings. |
||
| 1059 | * |
||
| 1060 | * @since 5.2.0 The new parameter $raw_output has been added. |
||
| 1061 | * |
||
| 1062 | * @param int $max_length Optional. The maximum number of bytes returned (0 for unlimited). Default 16. |
||
| 1063 | * @param bool $raw_output Optional. Wether to return raw binary data for the hash. Default true. |
||
| 1064 | * |
||
| 1065 | * @return string A binary hash value for the current settings limited to $max_length. |
||
| 1066 | */ |
||
| 1067 | public function get_hash( $max_length = 16, $raw_output = true ) { |
||
| 1076 | } |
||
| 1077 |