1 | <?php |
||||||
2 | /** |
||||||
3 | * This file is part of the sauls/helpers package. |
||||||
4 | * |
||||||
5 | * @author Saulius Vaičeliūnas <[email protected]> |
||||||
6 | * @link http://saulius.vaiceliunas.lt |
||||||
7 | * @copyright 2018 |
||||||
8 | * |
||||||
9 | * For the full copyright and license information, please view the LICENSE |
||||||
10 | * file that was distributed with this source code. |
||||||
11 | */ |
||||||
12 | |||||||
13 | namespace Sauls\Component\Helper; |
||||||
14 | |||||||
15 | use Sauls\Component\Helper\Operation\Factory\OperationFactory; |
||||||
16 | use Sauls\Component\Helper\Operation\StringOperation; |
||||||
17 | |||||||
18 | /** |
||||||
19 | * @throws \Exception |
||||||
20 | */ |
||||||
21 | function string_camelize(string $value): string |
||||||
22 | { |
||||||
23 | 5 | return OperationFactory::create(StringOperation\Camelize::class)->execute($value); |
|||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||
24 | } |
||||||
25 | |||||||
26 | /** |
||||||
27 | * @throws \Exception |
||||||
28 | */ |
||||||
29 | function string_snakeify(string $value): string |
||||||
30 | { |
||||||
31 | 3 | return OperationFactory::create(StringOperation\Snakeify::class)->execute($value); |
|||||
32 | } |
||||||
33 | |||||||
34 | /** |
||||||
35 | * @throws \Exception |
||||||
36 | */ |
||||||
37 | function explode_using_multi_delimiters(array $delimiters = ['.'], string $value): array |
||||||
38 | { |
||||||
39 | 1 | return OperationFactory::create(StringOperation\ExplodeWithMultiDelimiters::class)->execute($delimiters, $value); |
|||||
40 | } |
||||||
41 | |||||||
42 | /** |
||||||
43 | * @throws \Exception |
||||||
44 | */ |
||||||
45 | function base64_url_encode(string $value): string |
||||||
46 | { |
||||||
47 | 1 | return OperationFactory::create(StringOperation\Base64UrlEncode::class)->execute($value); |
|||||
48 | } |
||||||
49 | |||||||
50 | /** |
||||||
51 | * @throws \Exception |
||||||
52 | */ |
||||||
53 | function base64_url_decode(string $value): string |
||||||
54 | { |
||||||
55 | 1 | return OperationFactory::create(StringOperation\Base64Decode::class)->execute($value); |
|||||
56 | } |
||||||
57 | |||||||
58 | function count_words(string $value): int |
||||||
59 | { |
||||||
60 | 3 | return OperationFactory::create(StringOperation\CountWords::class)->execute($value); |
|||||
61 | } |
||||||
62 | |||||||
63 | function count_sentences(string $value): int |
||||||
64 | { |
||||||
65 | 2 | return OperationFactory::create(StringOperation\CountSentences::class)->execute($value); |
|||||
66 | } |
||||||
67 | |||||||
68 | function truncate(string $value, int $length, string $suffix = '...'): string |
||||||
69 | { |
||||||
70 | 4 | return OperationFactory::create(StringOperation\Truncate::class)->execute($value, $length, $suffix); |
|||||
71 | } |
||||||
72 | |||||||
73 | function truncate_words(string $value, int $count, string $suffix = '...'): string |
||||||
74 | { |
||||||
75 | 4 | return OperationFactory::create(StringOperation\TruncateWords::class)->execute($value, $count, $suffix); |
|||||
76 | } |
||||||
77 | |||||||
78 | function truncate_sentences(string $value, int $count, string $suffix = '...'): string |
||||||
79 | { |
||||||
80 | 7 | return OperationFactory::create(StringOperation\TruncateSentences::class)->execute($value, $count, $suffix); |
|||||
81 | } |
||||||
82 | |||||||
83 | function truncate_html(string $value, int $length, string $suffix): string |
||||||
84 | { |
||||||
85 | 1 | return OperationFactory::create(StringOperation\TruncateHtml::class)->execute($value, $length, $suffix); |
|||||
86 | } |
||||||
87 | |||||||
88 | function truncate_html_worlds(string $value, int $count, string $suffix = '...'): string |
||||||
89 | { |
||||||
90 | 1 | $truncateOperation = OperationFactory::create(StringOperation\TruncateHtml::class); |
|||||
91 | 1 | $truncateOperation->setTruncateOperationMethod(StringOperation\TruncateHtmlInterface::TRUNCATE_HTML_WORD); |
|||||
0 ignored issues
–
show
The method
setTruncateOperationMethod() does not exist on Sauls\Component\Helper\Operation\Operation . It seems like you code against a sub-type of Sauls\Component\Helper\Operation\Operation such as Sauls\Component\Helper\O...n\TruncateHtmlInterface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
92 | |||||||
93 | 1 | return $truncateOperation->execute($value, $count, $suffix); |
|||||
94 | } |
||||||
95 | |||||||
96 | function truncate_html_sentences(string $value, int $count, string $suffix = '...'): string |
||||||
97 | { |
||||||
98 | 3 | $truncateOperation = OperationFactory::create(StringOperation\TruncateHtml::class); |
|||||
99 | 3 | $truncateOperation->setTruncateOperationMethod(StringOperation\TruncateHtmlInterface::TRUNCATE_HTML_SENTENCE); |
|||||
100 | |||||||
101 | 3 | return $truncateOperation->execute($value, $count, $suffix); |
|||||
102 | } |
||||||
103 | |||||||
104 | function string_in(string $value, array $values): bool |
||||||
105 | { |
||||||
106 | 2 | return OperationFactory::create(StringOperation\StringIn::class)->execute($value, $values); |
|||||
107 | } |
||||||
108 | |||||||
109 | function string_contains(string $value, array $values): bool |
||||||
110 | { |
||||||
111 | 2 | return OperationFactory::create(StringOperation\StringContains::class)->execute($value, $values); |
|||||
112 | } |
||||||
113 |