Test Setup Failed
Push — master ( ca28ec...b6a302 )
by Alexey
03:56
created

TestCase   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A randomString() 0 11 2
1
<?php
2
/**
3
 * This file is part of the WoW-Apps/Symfony-Slack-Bot bundle for Symfony 3
4
 * https://github.com/wow-apps/symfony-slack-bot
5
 *
6
 * (c) 2016 WoW-Apps
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WowApps\SlackBundle\Tests;
13
14
use PHPUnit\Framework\TestCase as PHPUnitTestCase;
15
16
/**
17
 * Class TestCase
18
 * @author Alexey Samara <[email protected]>
19
 * @package WowApps\SlackBundle
20
 */
21
class TestCase extends PHPUnitTestCase
22
{
23
    const ARRAY_MIN_ITEMS = 2;
24
    const ARRAY_MAX_ITEMS = 10;
25
26
    /**
27
     * Create a random string
28
     *
29
     * @param int $length the length of the string to create
30
     * @return string
31
     * @author XEWeb <>
32
     */
33
    protected function randomString(int $length = 6): string
34
    {
35
        $str = '';
36
        $characters = array_merge(range('A','Z'), range('a','z'), range('0','9'));
37
        $max = count($characters) - 1;
38
        for ($i = 0; $i < $length; $i++) {
39
            $rand = mt_rand(0, $max);
40
            $str .= $characters[$rand];
41
        }
42
        return $str;
43
    }
44
}
45