helpers.php ➔ output()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 2
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Output the given text to the console.
5
 *
6
 * @param  string $output
7
 * @return void
8
 */
9
if (!function_exists('info')) {
10
    function info($output)
11
    {
12
        output('<info>' . $output . '</info>');
13
    }
14
}
15
16
/**
17
 * Output the given text to the console.
18
 *
19
 * @param  string $output
20
 * @return void
21
 */
22
if (!function_exists('output')) {
23
    function output($output)
24
    {
25
        if (isset($_ENV['APP_ENV']) && $_ENV['APP_ENV'] == 'testing') {
26
            return;
27
        }
28
        (new Symfony\Component\Console\Output\ConsoleOutput)->writeln($output);
29
    }
30
}
31
32
/**
33
 * Recursively copy files from one directory to another
34
 *
35
 * @param String $src - Source of files being moved
36
 * @param String $dest - Destination of files being moved
37
 * @return bool
38
 */
39
40
if (!function_exists('rcopy')) {
41
    function rcopy($src, $dest)
42
    {
43
44
        // If source is not a directory stop processing
45
        if (!is_dir($src)) return false;
46
47
        // If the destination directory does not exist create it
48
        if (!is_dir($dest)) {
49
            if (!mkdir($dest)) {
50
                // If the destination directory could not be created stop processing
51
                return false;
52
            }
53
        }
54
55
        // Open the source directory to read in files
56
        $i = new DirectoryIterator($src);
57
        foreach ($i as $f) {
58
            if ($f->isFile()) {
59
                copy($f->getRealPath(), "$dest/" . $f->getFilename());
60
            } else if (!$f->isDot() && $f->isDir()) {
61
                rcopy($f->getRealPath(), "$dest/$f");
62
            }
63
        }
64
    }
65
}