Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
n/a
0 / 0
0.00% covered (danger)
0.00%
0 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 19
ddebug
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
createFile777
0.00% covered (danger)
0.00%
0 / 1
20
0.00% covered (danger)
0.00%
0 / 9
processExec
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 5
js
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 3
1<?php
2
3use Symfony\Component\Process\Exception\ProcessFailedException;
4use Symfony\Component\Process\Process;
5
6/*
7 * Custom helper digital debug
8 */
9
10if (!function_exists('ddebug')) {
11    function ddebug($variable)
12    {
13        \Illuminate\Support\Facades\Log::debug(var_export($variable, true));
14    }
15}
16
17if (!function_exists('createFile777')) {
18    function createFile777($fullPath)
19    {
20        $fullPath = explode('/', $fullPath);
21
22        $filename = array_pop($fullPath);
23        $path = implode('/', $fullPath);
24
25        if (!is_dir($path) && !mkdir($path, 0777, true)) {
26            throw new Exception('Unable to create folder ...');
27        }
28
29        if (!file_exists($path . '/' . $filename)) {
30            touch($path . '/' . $filename);
31            chmod($path . '/' . $filename, 0777);
32        }
33    }
34}
35
36if (!function_exists('processExec')) {
37    function processExec(string $cmd)
38    {
39
40        $process = new Process(explode(' ', $cmd));
41        $process->run();
42
43        // executes after the command finishes
44        if (!$process->isSuccessful()) {
45            throw new ProcessFailedException($process);
46        }
47
48        return $process->getOutput();
49    }
50}
51
52if (!function_exists('js')) {
53    /**
54     * Return path of the given js file depending on the service
55     *
56     * @param string $filename
57     * @return string
58     */
59    function js(string $filename)
60    {
61        $format = '/var/www/html/vendor/qwamplify/%s/src/database/query/%s.js';
62        $filename = implode('/', explode('.', $filename));
63        return sprintf($format, getenv('SERVICE_NAME'), $filename);
64    }
65}