Completed
Pull Request — master (#36)
by
unknown
11:10
created

AsyncCommand::getSendMailOnError()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace App\Satis\Context;
4
5
use App\Satis\CommandContextInterface;
6
use Monolog\Formatter\LineFormatter;
7
use Monolog\Handler\StreamHandler;
8
use Monolog\Logger;
9
10
/**
11
 * @author Lukas Homza <[email protected]>
12
 */
13
class AsyncCommand implements CommandContextInterface {
14
    /**
15
     * @param string $logFile
16
     * @return string
17
     */
18
    public function getOutputRedirection($logFile) {
19
        return '&> ' . escapeshellarg($logFile);
20
    }
21
22
	/**
23
     * @return string
24
     */
25
    public function getShouldUnlockOnCompletion() {
26
        return ' && php artisan satis:persister:unlock';
27
    }
28
29
    /**
30
     * @param string $email
31
     * @param string $message
32
     * @return string
33
     */
34
    public function getSendMailOnError($email, $message)
35
    {
36
        return '|| echo "'.$message.'" | mail -s "Satis build failed" "'.$email.'"';
37
    }
38
39
    /**
40
     * @return \Monolog\Logger
41
     */
42 View Code Duplication
    public function getLogger() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
43
        $handler = new StreamHandler(storage_path('logs/builder_async.log'), Logger::DEBUG);
44
        $handler->setFormatter(new LineFormatter(null, null, true, true));
45
46
        $logger = new Logger('AsyncBuildLog');
47
        $logger->pushHandler($handler);
48
49
        return $logger;
50
    }
51
}
52