Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2declare(strict_types=1);
3/**
4 * Pop PHP Framework (https://www.popphp.org/)
5 *
6 * @link       https://github.com/popphp/popphp-framework
7 * @author     Nick Sagona, III <nick@popphp.org>
8 * @copyright  Copyright (c) 2009-2026 Nick Sagona, III
9 * @license    https://www.popphp.org/license     New BSD License
10 */
11
12/**
13 * @namespace
14 */
15namespace Pop\Utils;
16
17/**
18 * Pop utils arrayable interface
19 *
20 * @category   Pop
21 * @package    Pop\Utils
22 * @author     Nick Sagona, III <nick@popphp.org>
23 * @copyright  Copyright (c) 2009-2026 Nick Sagona, III
24 * @license    https://www.popphp.org/license     New BSD License
25 * @version    3.0.0
26 */
27interface ArrayableInterface
28{
29
30    /**
31     * Get the first item of the array
32     *
33     * @return mixed
34     */
35    public function first(): mixed;
36
37    /**
38     * Get the next item of the array
39     *
40     * @return mixed
41     */
42    public function next(): mixed;
43
44    /**
45     * Get the current item of the array
46     *
47     * @return mixed
48     */
49    public function current(): mixed;
50
51    /**
52     * Get the last item of the array
53     *
54     * @return mixed
55     */
56    public function last(): mixed;
57
58    /**
59     * Get the key of the current item of the array
60     *
61     * @return mixed
62     */
63    public function key(): mixed;
64
65    /**
66     * Determine if an item exists in the array
67     *
68     * @param  mixed $key
69     * @param  bool  $strict
70     * @return bool
71     */
72    public function contains(mixed $key, bool $strict = false): bool;
73
74    /**
75     * Sort array
76     *
77     * @param  int  $flags
78     * @param  bool $assoc
79     * @param  bool $descending
80     * @return static
81     */
82    public function sort(int $flags = SORT_REGULAR, bool $assoc = true, bool $descending = false): static;
83
84    /**
85     * Sort array descending
86     *
87     * @param  int  $flags
88     * @param  bool $assoc
89     * @return static
90     */
91    public function sortDesc(int $flags = SORT_REGULAR, bool $assoc = true): static;
92
93    /**
94     * Sort array by keys
95     *
96     * @param  int  $flags
97     * @param  bool $descending
98     * @return static
99     */
100    public function ksort(int $flags = SORT_REGULAR, bool $descending = false): static;
101
102    /**
103     * Sort array by keys, descending
104     *
105     * @param  int $flags
106     * @return static
107     */
108    public function ksortDesc(int $flags = SORT_REGULAR): static;
109
110    /**
111     * Sort array by user-defined callback
112     *
113     * @param  mixed $callback
114     * @param  bool  $assoc
115     * @return static
116     */
117    public function usort(mixed $callback, bool $assoc = true): static;
118
119    /**
120     * Sort array by user-defined callback using keys
121     *
122     * @param  mixed $callback
123     * @return static
124     */
125    public function uksort(mixed $callback): static;
126
127    /**
128     * Split a string into an array object
129     *
130     * @param  string $string
131     * @param  string $separator
132     * @param  int    $limit
133     * @return static
134     */
135    public static function split(string $string, string $separator, int $limit = PHP_INT_MAX): static;
136
137    /**
138     * Join the array values into a string
139     *
140     * @param  string $glue
141     * @param  string $finalGlue
142     * @return string
143     */
144    public function join(string $glue, string $finalGlue = ''): string;
145
146    /**
147     * Get the array object as an array.
148     *
149     * @return array
150     */
151    public function toArray(): array;
152
153}