PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 3.1.0
Defender Security – Malware Scanner, Login Security & Firewall v3.1.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / vendor / thecodingmachine / safe / generated / strings.php

strings.php in Defender Security – Malware Scanner, Login Security & Firewall 3.1.0, at vendor/thecodingmachine/safe/generated/strings.php

847 lines 16.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Safe;
4
5 use Safe\Exceptions\StringsException;
6
7 /**
8 * convert_uudecode decodes a uuencoded string.
9 *
10 * @param string $data The uuencoded data.
11 * @return string Returns the decoded data as a string.
12 * @throws StringsException
13 *
14 */
15 function convert_uudecode(string $data): string
16 {
17 error_clear_last();
18 $result = \convert_uudecode($data);
19 if ($result === false) {
20 throw StringsException::createFromPhpError();
21 }
22 return $result;
23 }
24
25
26 /**
27 * convert_uuencode encodes a string using the uuencode
28 * algorithm.
29 *
30 * Uuencode translates all strings (including binary data) into printable
31 * characters, making them safe for network transmissions. Uuencoded data is
32 * about 35% larger than the original.
33 *
34 * @param string $data The data to be encoded.
35 * @return string Returns the uuencoded data.
36 * @throws StringsException
37 *
38 */
39 function convert_uuencode(string $data): string
40 {
41 error_clear_last();
42 $result = \convert_uuencode($data);
43 if ($result === false) {
44 throw StringsException::createFromPhpError();
45 }
46 return $result;
47 }
48
49
50 /**
51 * Decodes a hexadecimally encoded binary string.
52 *
53 * @param string $data Hexadecimal representation of data.
54 * @return string Returns the binary representation of the given data.
55 * @throws StringsException
56 *
57 */
58 function hex2bin(string $data): string
59 {
60 error_clear_last();
61 $result = \hex2bin($data);
62 if ($result === false) {
63 throw StringsException::createFromPhpError();
64 }
65 return $result;
66 }
67
68
69 /**
70 * Calculates the MD5 hash of the file specified by the
71 * filename parameter using the
72 * RSA Data Security, Inc.
73 * MD5 Message-Digest Algorithm, and returns that hash.
74 * The hash is a 32-character hexadecimal number.
75 *
76 * @param string $filename The filename
77 * @param bool $raw_output When TRUE, returns the digest in raw binary format with a length of
78 * 16.
79 * @return string Returns a string on success, FALSE otherwise.
80 * @throws StringsException
81 *
82 */
83 function md5_file(string $filename, bool $raw_output = false): string
84 {
85 error_clear_last();
86 $result = \md5_file($filename, $raw_output);
87 if ($result === false) {
88 throw StringsException::createFromPhpError();
89 }
90 return $result;
91 }
92
93
94 /**
95 * Calculates the metaphone key of str.
96 *
97 * Similar to soundex metaphone creates the same key for
98 * similar sounding words. It's more accurate than
99 * soundex as it knows the basic rules of English
100 * pronunciation. The metaphone generated keys are of variable length.
101 *
102 * Metaphone was developed by Lawrence Philips
103 * &lt;lphilips at verity dot com&gt;. It is described in ["Practical
104 * Algorithms for Programmers", Binstock &amp; Rex, Addison Wesley,
105 * 1995].
106 *
107 * @param string $str The input string.
108 * @param int $phonemes This parameter restricts the returned metaphone key to
109 * phonemes characters in length.
110 * The default value of 0 means no restriction.
111 * @return string Returns the metaphone key as a string.
112 * @throws StringsException
113 *
114 */
115 function metaphone(string $str, int $phonemes = 0): string
116 {
117 error_clear_last();
118 $result = \metaphone($str, $phonemes);
119 if ($result === false) {
120 throw StringsException::createFromPhpError();
121 }
122 return $result;
123 }
124
125
126 /**
127 *
128 *
129 * @param string $filename The filename of the file to hash.
130 * @param bool $raw_output When TRUE, returns the digest in raw binary format with a length of
131 * 20.
132 * @return string Returns a string on success, FALSE otherwise.
133 * @throws StringsException
134 *
135 */
136 function sha1_file(string $filename, bool $raw_output = false): string
137 {
138 error_clear_last();
139 $result = \sha1_file($filename, $raw_output);
140 if ($result === false) {
141 throw StringsException::createFromPhpError();
142 }
143 return $result;
144 }
145
146
147 /**
148 * Calculates the soundex key of str.
149 *
150 * Soundex keys have the property that words pronounced similarly
151 * produce the same soundex key, and can thus be used to simplify
152 * searches in databases where you know the pronunciation but not
153 * the spelling. This soundex function returns a string 4 characters
154 * long, starting with a letter.
155 *
156 * This particular soundex function is one described by Donald Knuth
157 * in "The Art Of Computer Programming, vol. 3: Sorting And
158 * Searching", Addison-Wesley (1973), pp. 391-392.
159 *
160 * @param string $str The input string.
161 * @return string Returns the soundex key as a string.
162 * @throws StringsException
163 *
164 */
165 function soundex(string $str): string
166 {
167 error_clear_last();
168 $result = \soundex($str);
169 if ($result === false) {
170 throw StringsException::createFromPhpError();
171 }
172 return $result;
173 }
174
175
176 /**
177 * Returns a string produced according to the formatting string
178 * format.
179 *
180 * @param string $format The format string is composed of zero or more directives:
181 * ordinary characters (excluding %) that are
182 * copied directly to the result and conversion
183 * specifications, each of which results in fetching its
184 * own parameter.
185 *
186 * A conversion specification follows this prototype:
187 * %[argnum$][flags][width][.precision]specifier.
188 *
189 * An integer followed by a dollar sign $,
190 * to specify which number argument to treat in the conversion.
191 *
192 *
193 * Flags
194 *
195 *
196 *
197 * Flag
198 * Description
199 *
200 *
201 *
202 *
203 * -
204 *
205 * Left-justify within the given field width;
206 * Right justification is the default
207 *
208 *
209 *
210 * +
211 *
212 * Prefix positive numbers with a plus sign
213 * +; Default only negative
214 * are prefixed with a negative sign.
215 *
216 *
217 *
218 * (space)
219 *
220 * Pads the result with spaces.
221 * This is the default.
222 *
223 *
224 *
225 * 0
226 *
227 * Only left-pads numbers with zeros.
228 * With s specifiers this can
229 * also right-pad with zeros.
230 *
231 *
232 *
233 * '(char)
234 *
235 * Pads the result with the character (char).
236 *
237 *
238 *
239 *
240 *
241 *
242 * An integer that says how many characters (minimum)
243 * this conversion should result in.
244 *
245 * A period . followed by an integer
246 * who's meaning depends on the specifier:
247 *
248 *
249 *
250 * For e, E,
251 * f and F
252 * specifiers: this is the number of digits to be printed
253 * after the decimal point (by default, this is 6).
254 *
255 *
256 *
257 *
258 * For g and G
259 * specifiers: this is the maximum number of significant
260 * digits to be printed.
261 *
262 *
263 *
264 *
265 * For s specifier: it acts as a cutoff point,
266 * setting a maximum character limit to the string.
267 *
268 *
269 *
270 *
271 *
272 * If the period is specified without an explicit value for precision,
273 * 0 is assumed.
274 *
275 *
276 *
277 *
278 * Specifiers
279 *
280 *
281 *
282 * Specifier
283 * Description
284 *
285 *
286 *
287 *
288 * %
289 *
290 * A literal percent character. No argument is required.
291 *
292 *
293 *
294 * b
295 *
296 * The argument is treated as an integer and presented
297 * as a binary number.
298 *
299 *
300 *
301 * c
302 *
303 * The argument is treated as an integer and presented
304 * as the character with that ASCII.
305 *
306 *
307 *
308 * d
309 *
310 * The argument is treated as an integer and presented
311 * as a (signed) decimal number.
312 *
313 *
314 *
315 * e
316 *
317 * The argument is treated as scientific notation (e.g. 1.2e+2).
318 * The precision specifier stands for the number of digits after the
319 * decimal point since PHP 5.2.1. In earlier versions, it was taken as
320 * number of significant digits (one less).
321 *
322 *
323 *
324 * E
325 *
326 * Like the e specifier but uses
327 * uppercase letter (e.g. 1.2E+2).
328 *
329 *
330 *
331 * f
332 *
333 * The argument is treated as a float and presented
334 * as a floating-point number (locale aware).
335 *
336 *
337 *
338 * F
339 *
340 * The argument is treated as a float and presented
341 * as a floating-point number (non-locale aware).
342 * Available as of PHP 5.0.3.
343 *
344 *
345 *
346 * g
347 *
348 *
349 * General format.
350 *
351 *
352 * Let P equal the precision if nonzero, 6 if the precision is omitted,
353 * or 1 if the precision is zero.
354 * Then, if a conversion with style E would have an exponent of X:
355 *
356 *
357 * If P &gt; X ≥ −4, the conversion is with style f and precision P − (X + 1).
358 * Otherwise, the conversion is with style e and precision P − 1.
359 *
360 *
361 *
362 *
363 * G
364 *
365 * Like the g specifier but uses
366 * E and f.
367 *
368 *
369 *
370 * o
371 *
372 * The argument is treated as an integer and presented
373 * as an octal number.
374 *
375 *
376 *
377 * s
378 *
379 * The argument is treated and presented as a string.
380 *
381 *
382 *
383 * u
384 *
385 * The argument is treated as an integer and presented
386 * as an unsigned decimal number.
387 *
388 *
389 *
390 * x
391 *
392 * The argument is treated as an integer and presented
393 * as a hexadecimal number (with lowercase letters).
394 *
395 *
396 *
397 * X
398 *
399 * The argument is treated as an integer and presented
400 * as a hexadecimal number (with uppercase letters).
401 *
402 *
403 *
404 *
405 *
406 *
407 * General format.
408 *
409 * Let P equal the precision if nonzero, 6 if the precision is omitted,
410 * or 1 if the precision is zero.
411 * Then, if a conversion with style E would have an exponent of X:
412 *
413 * If P &gt; X ≥ −4, the conversion is with style f and precision P − (X + 1).
414 * Otherwise, the conversion is with style e and precision P − 1.
415 *
416 * The c type specifier ignores padding and width
417 *
418 * Attempting to use a combination of the string and width specifiers with character sets that require more than one byte per character may result in unexpected results
419 *
420 * Variables will be co-erced to a suitable type for the specifier:
421 *
422 * Type Handling
423 *
424 *
425 *
426 * Type
427 * Specifiers
428 *
429 *
430 *
431 *
432 * string
433 * s
434 *
435 *
436 * integer
437 *
438 * d,
439 * u,
440 * c,
441 * o,
442 * x,
443 * X,
444 * b
445 *
446 *
447 *
448 * double
449 *
450 * g,
451 * G,
452 * e,
453 * E,
454 * f,
455 * F
456 *
457 *
458 *
459 *
460 *
461 * @param mixed $params
462 * @return string Returns a string produced according to the formatting string
463 * format.
464 * @throws StringsException
465 *
466 */
467 function sprintf(string $format, ...$params): string
468 {
469 error_clear_last();
470 if ($params !== []) {
471 $result = \sprintf($format, ...$params);
472 } else {
473 $result = \sprintf($format);
474 }
475 if ($result === false) {
476 throw StringsException::createFromPhpError();
477 }
478 return $result;
479 }
480
481
482 /**
483 * Returns the portion of string specified by the
484 * start and length parameters.
485 *
486 * @param string $string The input string.
487 * @param int $start If start is non-negative, the returned string
488 * will start at the start'th position in
489 * string, counting from zero. For instance,
490 * in the string 'abcdef', the character at
491 * position 0 is 'a', the
492 * character at position 2 is
493 * 'c', and so forth.
494 *
495 * If start is negative, the returned string
496 * will start at the start'th character
497 * from the end of string.
498 *
499 * If string is less than
500 * start characters long, FALSE will be returned.
501 *
502 *
503 * Using a negative start
504 *
505 *
506 * ]]>
507 *
508 *
509 * @param int $length If length is given and is positive, the string
510 * returned will contain at most length characters
511 * beginning from start (depending on the length of
512 * string).
513 *
514 * If length is given and is negative, then that many
515 * characters will be omitted from the end of string
516 * (after the start position has been calculated when a
517 * start is negative). If
518 * start denotes the position of this truncation or
519 * beyond, FALSE will be returned.
520 *
521 * If length is given and is 0,
522 * FALSE or NULL, an empty string will be returned.
523 *
524 * If length is omitted, the substring starting from
525 * start until the end of the string will be
526 * returned.
527 * @return string Returns the extracted part of string;, or
528 * an empty string.
529 * @throws StringsException
530 *
531 */
532 function substr(string $string, int $start, int $length = null): string
533 {
534 error_clear_last();
535 if ($length !== null) {
536 $result = \substr($string, $start, $length);
537 } else {
538 $result = \substr($string, $start);
539 }
540 if ($result === false) {
541 throw StringsException::createFromPhpError();
542 }
543 return $result;
544 }
545
546
547 /**
548 * Operates as sprintf but accepts an array of
549 * arguments, rather than a variable number of arguments.
550 *
551 * @param string $format The format string is composed of zero or more directives:
552 * ordinary characters (excluding %) that are
553 * copied directly to the result and conversion
554 * specifications, each of which results in fetching its
555 * own parameter.
556 *
557 * A conversion specification follows this prototype:
558 * %[argnum$][flags][width][.precision]specifier.
559 *
560 * An integer followed by a dollar sign $,
561 * to specify which number argument to treat in the conversion.
562 *
563 *
564 * Flags
565 *
566 *
567 *
568 * Flag
569 * Description
570 *
571 *
572 *
573 *
574 * -
575 *
576 * Left-justify within the given field width;
577 * Right justification is the default
578 *
579 *
580 *
581 * +
582 *
583 * Prefix positive numbers with a plus sign
584 * +; Default only negative
585 * are prefixed with a negative sign.
586 *
587 *
588 *
589 * (space)
590 *
591 * Pads the result with spaces.
592 * This is the default.
593 *
594 *
595 *
596 * 0
597 *
598 * Only left-pads numbers with zeros.
599 * With s specifiers this can
600 * also right-pad with zeros.
601 *
602 *
603 *
604 * '(char)
605 *
606 * Pads the result with the character (char).
607 *
608 *
609 *
610 *
611 *
612 *
613 * An integer that says how many characters (minimum)
614 * this conversion should result in.
615 *
616 * A period . followed by an integer
617 * who's meaning depends on the specifier:
618 *
619 *
620 *
621 * For e, E,
622 * f and F
623 * specifiers: this is the number of digits to be printed
624 * after the decimal point (by default, this is 6).
625 *
626 *
627 *
628 *
629 * For g and G
630 * specifiers: this is the maximum number of significant
631 * digits to be printed.
632 *
633 *
634 *
635 *
636 * For s specifier: it acts as a cutoff point,
637 * setting a maximum character limit to the string.
638 *
639 *
640 *
641 *
642 *
643 * If the period is specified without an explicit value for precision,
644 * 0 is assumed.
645 *
646 *
647 *
648 *
649 * Specifiers
650 *
651 *
652 *
653 * Specifier
654 * Description
655 *
656 *
657 *
658 *
659 * %
660 *
661 * A literal percent character. No argument is required.
662 *
663 *
664 *
665 * b
666 *
667 * The argument is treated as an integer and presented
668 * as a binary number.
669 *
670 *
671 *
672 * c
673 *
674 * The argument is treated as an integer and presented
675 * as the character with that ASCII.
676 *
677 *
678 *
679 * d
680 *
681 * The argument is treated as an integer and presented
682 * as a (signed) decimal number.
683 *
684 *
685 *
686 * e
687 *
688 * The argument is treated as scientific notation (e.g. 1.2e+2).
689 * The precision specifier stands for the number of digits after the
690 * decimal point since PHP 5.2.1. In earlier versions, it was taken as
691 * number of significant digits (one less).
692 *
693 *
694 *
695 * E
696 *
697 * Like the e specifier but uses
698 * uppercase letter (e.g. 1.2E+2).
699 *
700 *
701 *
702 * f
703 *
704 * The argument is treated as a float and presented
705 * as a floating-point number (locale aware).
706 *
707 *
708 *
709 * F
710 *
711 * The argument is treated as a float and presented
712 * as a floating-point number (non-locale aware).
713 * Available as of PHP 5.0.3.
714 *
715 *
716 *
717 * g
718 *
719 *
720 * General format.
721 *
722 *
723 * Let P equal the precision if nonzero, 6 if the precision is omitted,
724 * or 1 if the precision is zero.
725 * Then, if a conversion with style E would have an exponent of X:
726 *
727 *
728 * If P &gt; X ≥ −4, the conversion is with style f and precision P − (X + 1).
729 * Otherwise, the conversion is with style e and precision P − 1.
730 *
731 *
732 *
733 *
734 * G
735 *
736 * Like the g specifier but uses
737 * E and f.
738 *
739 *
740 *
741 * o
742 *
743 * The argument is treated as an integer and presented
744 * as an octal number.
745 *
746 *
747 *
748 * s
749 *
750 * The argument is treated and presented as a string.
751 *
752 *
753 *
754 * u
755 *
756 * The argument is treated as an integer and presented
757 * as an unsigned decimal number.
758 *
759 *
760 *
761 * x
762 *
763 * The argument is treated as an integer and presented
764 * as a hexadecimal number (with lowercase letters).
765 *
766 *
767 *
768 * X
769 *
770 * The argument is treated as an integer and presented
771 * as a hexadecimal number (with uppercase letters).
772 *
773 *
774 *
775 *
776 *
777 *
778 * General format.
779 *
780 * Let P equal the precision if nonzero, 6 if the precision is omitted,
781 * or 1 if the precision is zero.
782 * Then, if a conversion with style E would have an exponent of X:
783 *
784 * If P &gt; X ≥ −4, the conversion is with style f and precision P − (X + 1).
785 * Otherwise, the conversion is with style e and precision P − 1.
786 *
787 * The c type specifier ignores padding and width
788 *
789 * Attempting to use a combination of the string and width specifiers with character sets that require more than one byte per character may result in unexpected results
790 *
791 * Variables will be co-erced to a suitable type for the specifier:
792 *
793 * Type Handling
794 *
795 *
796 *
797 * Type
798 * Specifiers
799 *
800 *
801 *
802 *
803 * string
804 * s
805 *
806 *
807 * integer
808 *
809 * d,
810 * u,
811 * c,
812 * o,
813 * x,
814 * X,
815 * b
816 *
817 *
818 *
819 * double
820 *
821 * g,
822 * G,
823 * e,
824 * E,
825 * f,
826 * F
827 *
828 *
829 *
830 *
831 *
832 * @param array $args
833 * @return string Return array values as a formatted string according to
834 * format.
835 * @throws StringsException
836 *
837 */
838 function vsprintf(string $format, array $args): string
839 {
840 error_clear_last();
841 $result = \vsprintf($format, $args);
842 if ($result === false) {
843 throw StringsException::createFromPhpError();
844 }
845 return $result;
846 }
847