File size: 655 Bytes
d2897cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php

namespace Mautic\LeadBundle\Segment;

class RandomParameterName
{
    /**
     * @var int
     */
    protected $lastUsedParameterId = 0;

    /**
     * Generate a unique parameter name from int using base conversion.
     * This eliminates chance for parameter name collision and provides unique result for each number.
     *
     * @see https://stackoverflow.com/questions/307486/short-unique-id-in-php/1516430#1516430
     */
    public function generateRandomParameterName(): string
    {
        $value = base_convert((string) $this->lastUsedParameterId, 10, 36);

        ++$this->lastUsedParameterId;

        return 'par'.$value;
    }
}