Passed
Pull Request — master (#13)
by Prasit
13:26
created

InvoiceReferenceGenerator::generate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Soap\Invoices;
4
5
use Carbon\Carbon;
6
7
/**
8
 * Generate invoice reference identification string
9
 * @todo format should be user settable
10
 * @package Soap\Invoices
11
 */
12
class InvoiceReferenceGenerator
13
{
14 50
    public static function generate()
15
    {
16 50
        $date = Carbon::now();
17 50
        return $date->format('Y-m-d') . '-' . self::generateRandomCode();
18
    }
19
20 50
    protected static function generateRandomCode()
21
    {
22 50
        $pool = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789';
23 50
        return substr(str_shuffle(str_repeat($pool, 6)), 0, 6);
24
    }
25
}
26