Skip to content

Commit 5de4f98

Browse files
authored
Add api documentations (#2)
1 parent 1efbfbf commit 5de4f98

File tree

5 files changed

+43
-27
lines changed

5 files changed

+43
-27
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,6 @@ $RECYCLE.BIN/
9090
# End of https://www.toptal.com/developers/gitignore/api/composer,macos,windows,visualstudiocode
9191

9292
composer.lock
93+
/build
94+
/cache
95+
/doctum.php

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# Array Flatten
22

3-
[![Tests](https://github.com/cable8mm/array-flatten/actions/workflows/tests.yml/badge.svg)](https://github.com/cable8mm/array-flatten/actions/workflows/tests.yml)
4-
[![PHP Linting (Pint)](https://github.com/cable8mm/array-flatten/actions/workflows/coding-style-php.yml/badge.svg)](https://github.com/cable8mm/array-flatten/actions/workflows/coding-style-php.yml)
5-
[![Latest Stable Version](http://poser.pugx.org/cable8mm/array-flatten/v)](https://packagist.org/packages/cable8mm/array-flatten)
6-
[![Total Downloads](http://poser.pugx.org/cable8mm/array-flatten/downloads)](https://packagist.org/packages/cable8mm/array-flatten)
7-
[![release date](https://img.shields.io/github/release-date/cable8mm/array-flatten)](https://github.com/cable8mm/array-flatten/releases)
8-
![GitHub License](https://img.shields.io/github/license/cable8mm/array-flatten)
9-
[![PHP Version Require](http://poser.pugx.org/cable8mm/array-flatten/require/php)](https://packagist.org/packages/cable8mm/array-flatten)
10-
11-
> Flatten nested arrays.
3+
[![code-style](https://github.com/cable8mm/array-flatten/actions/workflows/code-style.yml/badge.svg)](https://github.com/cable8mm/array-flatten/actions/workflows/code-style.yml)
4+
[![run-tests](https://github.com/cable8mm/array-flatten/actions/workflows/run-tests.yml/badge.svg)](https://github.com/cable8mm/array-flatten/actions/workflows/run-tests.yml)
5+
![Packagist Version](https://img.shields.io/packagist/v/cable8mm/array-flatten)
6+
![Packagist Downloads](https://img.shields.io/packagist/dt/cable8mm/array-flatten)
7+
![Packagist Dependency Version](https://img.shields.io/packagist/dependency-v/cable8mm/array-flatten/php)
8+
![Packagist Stars](https://img.shields.io/packagist/stars/cable8mm/array-flatten)
9+
![Packagist License](https://img.shields.io/packagist/l/cable8mm/array-flatten)
10+
11+
Flatten nested arrays.
12+
13+
We have provided the API Documentation on the web. For more information, please visit https://www.palgle.com/array-flatten/ ❤️
1214

1315
## Installation
1416

composer.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,10 @@
3030
"laravel/pint": "^1.0"
3131
},
3232
"scripts": {
33-
"test": [
34-
"./vendor/bin/phpunit"
35-
],
36-
"lint": [
37-
"./vendor/bin/pint"
38-
]
33+
"test": "./vendor/bin/phpunit tests",
34+
"lint": "./vendor/bin/pint",
35+
"inspect": "./vendor/bin/pint --test",
36+
"apidoc": "doctum.phar update doctum.php --output-format=github --no-ansi --no-progress"
3937
},
4038
"minimum-stability": "stable",
4139
"prefer-stable": true

phpunit.xml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd"
4-
bootstrap="vendor/autoload.php"
5-
cacheDirectory=".phpunit.cache"
6-
executionOrder="depends,defects"
7-
beStrictAboutCoverageMetadata="true"
8-
beStrictAboutOutputDuringTests="true"
9-
failOnRisky="true"
10-
failOnWarning="true"
11-
cacheResult ="false">
3+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
testdox="true">
127
<testsuites>
138
<testsuite name="default">
149
<directory>tests</directory>
1510
</testsuite>
1611
</testsuites>
1712

18-
<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
13+
<source>
1914
<include>
2015
<directory>src</directory>
2116
</include>
2217
</source>
23-
</phpunit>
18+
</phpunit>

src/array_flatten.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
namespace Cable8mm\ArrayFlatten;
44

5+
/**
6+
* Flatten nested arrays. * array_flatten([1, [2, [3, [4, [5], 6], 7], 8], 9]); //=> [1, 2, 3, 4, 5, 6, 7, 8, 9]
7+
*
8+
* @param array $array The nested arrays
9+
* @return array The array to flatten
10+
*
11+
* @example array_flatten([1, [2, [3, [4, [5], 6], 7], 8], 9]);
12+
* //=> [1, 2, 3, 4, 5, 6, 7, 8, 9]
13+
*/
514
function array_flatten(array $array): array
615
{
716
$return = [];
@@ -13,7 +22,16 @@ function array_flatten(array $array): array
1322
return array_raw_unique($return);
1423
}
1524

16-
function array_raw_unique(array $array)
25+
/**
26+
* Extend array_unique() to include null and space values. array_raw_unique([1, 2, 2, null, null, '', '', 9]); //=> [1, 2, null, '', '', 9]
27+
*
28+
* @param array $array The array
29+
* @return array The unique array even if it contains null and space values
30+
*
31+
* @example array_raw_unique([1, 2, 2, null, null, '', '', 9]);
32+
* //=> [1, 2, null, '', '', 9]
33+
*/
34+
function array_raw_unique(array $array): array
1735
{
1836
$out = [];
1937

0 commit comments

Comments
 (0)