InstalledFileManager   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 34
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 17 2
A update() 0 3 1
1
<?php
2
3
namespace Turahe\LaravelInstaller\Helpers;
4
5
/**
6
 * Class InstalledFileManager.
7
 */
8
class InstalledFileManager
9
{
10
    /**
11
     * Create installed file.
12
     *
13
     * @return int
14
     */
15
    public function create()
16
    {
17
        $installedLogFile = storage_path('installed');
18
19
        $dateStamp = date('Y/m/d h:i:sa');
20
21
        if (! file_exists($installedLogFile)) {
22
            $message = trans('installer_messages.installed.success_log_message').$dateStamp."\n";
0 ignored issues
show
Bug introduced by
Are you sure trans('installer_message...d.success_log_message') of type array|string can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

22
            $message = /** @scrutinizer ignore-type */ trans('installer_messages.installed.success_log_message').$dateStamp."\n";
Loading history...
23
24
            file_put_contents($installedLogFile, $message);
25
        } else {
26
            $message = trans('installer_messages.updater.log.success_message').$dateStamp;
0 ignored issues
show
Bug introduced by
Are you sure trans('installer_message...r.log.success_message') of type array|string can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

26
            $message = /** @scrutinizer ignore-type */ trans('installer_messages.updater.log.success_message').$dateStamp;
Loading history...
27
28
            file_put_contents($installedLogFile, $message.PHP_EOL, FILE_APPEND | LOCK_EX);
29
        }
30
31
        return $message;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $message returns the type string which is incompatible with the documented return type integer.
Loading history...
32
    }
33
34
    /**
35
     * Update installed file.
36
     *
37
     * @return int
38
     */
39
    public function update()
40
    {
41
        return $this->create();
42
    }
43
}
44