Commit a85b5090 authored by Akex's avatar Akex
Browse files

create test data | create func

parent 2a7f91b8
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
<?php

namespace App\Actions;

class UniqElementsAction
{
    /**
     * Удаляет дубликаты, оставив только уникальные значения
     * @param array $array
     * @return array
     */
    public static function uniqElements(array $array): array
    {
        return array_unique($array, SORT_REGULAR);
    }
}
 No newline at end of file
+18 −1
Original line number Diff line number Diff line
@@ -8,5 +8,22 @@ namespace App\TestData;

class TestData
{

    public const NON_UNIQE_ARRAY = [
        [
            'laravel',
            'php',
        ],
        [
            'codeigniter',
            'php',
        ],
        [
            'laravel',
            'php',
        ],
        [
            'c++',
            'java',
        ],
    ];
}
+2 −1
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

require_once __DIR__ . '/../vendor/autoload.php';

use App\Actions /*placeholder for a class */;
use App\Actions\UniqElementsAction;
use App\TestData\TestData;

var_dump(UniqElementsAction::uniqElements(TestData::NON_UNIQE_ARRAY));