• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

znframework / fullpack-edition / 8716966645

17 Apr 2024 05:48AM UTC coverage: 98.608% (-1.0%) from 99.589%
8716966645

push

github

zntr
Updated test.yml

10341 of 10487 relevant lines covered (98.61%)

33.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.67
/Internal/package-datatypes/Strings.php
1
<?php namespace ZN\DataTypes;
2
/**
3
 * ZN PHP Web Framework
4
 * 
5
 * "Simplicity is the ultimate sophistication." ~ Da Vinci
6
 * 
7
 * @package ZN
8
 * @license MIT [http://opensource.org/licenses/MIT]
9
 * @author  Ozan UYKUN [ozan@znframework.com]
10
 */
11

12
use ZN\Helper;
13
use ZN\Controller\Factory;
14
use ZN\Ability\Functionalization;
15

16
class Strings extends Factory
17
{
18
    use Functionalization;
19

20
    const factory =
21
    [
22
        'methods' =>
23
        [
24
            'mtrim'            => 'Strings\Trim::middle',
25
            'trimslashes'      => 'Strings\Trim::slashes',
26
            'addprefix'        => 'Strings\Trim::prefix',
27
            'removeprefix'     => 'Strings\Trim::removePrefix',
28
            'addsuffix'        => 'Strings\Trim::suffix',
29
            'removesuffix'     => 'Strings\Trim::removeSuffix',
30
            'addbothfix'       => 'Strings\Trim::presuffix',
31
            'removebothfix'    => 'Strings\Trim::removePresuffix',
32
            'casing'           => 'Strings\Casing::use',
33
            'lowercase'        => 'Strings\Casing::lower',
34
            'uppercase'        => 'Strings\Casing::upper',
35
            'titlecase'        => 'Strings\Casing::title',
36
            'pascalcase'       => 'Strings\Casing::pascal',
37
            'camelcase'        => 'Strings\Casing::camel',
38
            'underscorecase'   => 'Strings\Casing::underscore',
39
            'search'           => 'Strings\Search::use',
40
            'searchposition'   => 'Strings\Search::position',
41
            'searchstring'     => 'Strings\Search::string',
42
            'searchbetween'    => 'Strings\Search::between',
43
            'searchbetweenboth'=> 'Strings\Search::betweenBoth',
44
            'reshuffle'        => 'Strings\Substitution::reshuffle',
45
            'placement'        => 'Strings\Substitution::placement',
46
            'replace'          => 'Strings\Substitution::replace',
47
            'repeatcomplete'   => 'Strings\Substitution::repeatComplete',
48
            'addslashes'       => 'Strings\Security::addSlashes',
49
            'removeslashes'    => 'Strings\Security::removeSlashes',
50
            'section'          => 'Strings\Section::use',
51
            'splituppercase'   => 'Strings\Split::upperCase',
52
            'apportion'        => 'Strings\Split::apportion',
53
            'divide'           => 'Strings\Split::divide',
54
            'removeelement'    => 'Strings\Element::remove',
55
            'removefirst'      => 'Strings\Element::removeFirst',
56
            'removelast'       => 'Strings\Element::removeLast',
57
        ]
58
    ];
59

60
    /**
61
     * Functionalization
62
     * 
63
     * @var array
64
     */
65
    const functionalization = 
66
    [
67
        'repeat' => 'str_repeat',
68
        'length' => 'mb_strlen',
69
        'split'  => 'str_split'
70
    ];
71

72
    /**
73
     * String to Array
74
     * 
75
     * @param string $string
76
     * @param string $split = ' '
77
     * 
78
     * @return array
79
     */
80
    public static function toArray(string $string, string $split = ' ')
81
    {
82
        if( empty($split) )
4✔
83
        {
84
            return str_split($string, 1); // @codeCoverageIgnore
85
        }
86

87
        return explode($split, $string);
4✔
88
    }
89

90
    /**
91
     * Pad
92
     * 
93
     * @param string $string
94
     * @param int    $count = 1
95
     * @param string $chars = ' '
96
     * @param string $type  = 'right' - options[right|left|both]
97
     * 
98
     * @return string
99
     */
100
    public static function pad(string $string, int $count = 1, string $chars = ' ', string $type = 'right') : string
101
    {
102
        return str_pad($string, $count, $chars, Helper::toConstant($type, 'STR_PAD_'));
2✔
103
    }
104

105
    /**
106
     * Recurrent Count
107
     * 
108
     * @param string $str
109
     * @param string $char
110
     * 
111
     * @return int
112
     */
113
    public static function recurrentCount(string $str, string $char) : int
114
    {
115
        return count(explode($char, $str)) - 1;
2✔
116
    }
117

118
    /**
119
     * Unserialize
120
     * 
121
     * @param string $str
122
     * 
123
     * @return array
124
     */
125
    public static function unserialize(string $str) : array
126
    {
127
        parse_str(urldecode($str), $array);
×
128

129
        return $array;
×
130
    }
131
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc