GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

FileNameBuilder   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 37
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A build() 0 10 2
1
<?php
2
3
namespace Dami\Migration;
4
5
use Stringy\StaticStringy as S;
6
7
class FileNameBuilder
8
{
9
    private $migrationName;
10
11
    /**
12
     * Constructor.
13
     *
14
     * @param string $migrationName Migration name.
15
     *
16
     * @throws InvalidArgumentException If the $migrationName is missing or null.
17
     */
18
    public function __construct($migrationName = null)
19
    {
20
        if (null === $migrationName) {
21
            throw new \InvalidArgumentException('Migration name is required.');
22
        }
23
        $this->migrationName = $migrationName;
24
    }
25
26
    /**
27
     * Build migration file name.
28
     *
29
     * @param datatype $timestamp Timestamp of migration.
30
     *
31
     * @return string
32
     */
33
    public function build($timestamp = null)
34
    {
35
        if (null === $timestamp) {
36
            $timestamp = new \DateTime();
37
            $timestamp = $timestamp->format('YmdHis');
38
        }
39
        $fileName = sprintf('%s_%s.php', $timestamp, S::underscored($this->migrationName));
40
41
        return $fileName;
42
    }
43
}
44