base64_url_decode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
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
The method execute() does not exist on Sauls\Component\Helper\Operation\Operation. It seems like you code against a sub-type of said class. However, the method does not exist in Sauls\Component\Helper\O...ation\ToObjectInterface or Sauls\Component\Helper\O...ArrayOperation\ToObject. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
    return OperationFactory::create(StringOperation\Camelize::class)->/** @scrutinizer ignore-call */ execute($value);
Loading history...
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
Bug introduced by
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 ignore-call  annotation

91
    $truncateOperation->/** @scrutinizer ignore-call */ 
92
                        setTruncateOperationMethod(StringOperation\TruncateHtmlInterface::TRUNCATE_HTML_WORD);
Loading history...
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