Unlink_Directory::removeDirectory()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 4
eloc 7
nc 4
nop 1
dl 0
loc 11
rs 10
c 1
b 0
f 1
1
<?php
2
/** 
3
 * Copyright 2018 Social Manager.
4
 * 
5
 * PHP version 7.2.8
6
 *
7
 * @category Album_Manager
8
 * @package  HelperClass
9
 * @author   Kishan Jasani <[email protected]>
10
 * @license  https://localhost/SocialManager/privacy_policy/privacy_policy.php 
11
 * @link     ""
12
 * You are hereby granted a non-exclusive, worldwide, royalty-free license to
13
 * use, copy, modify, and distribute this software in source code or binary
14
 * form for use in connection with the web services and APIs provided by
15
 * Kishan Jasani.
16
 *
17
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND
18
 */
19
class Unlink_Directory
20
{
21
    /**
22
     * Remove the album directory
23
     * 
24
     * @param String $directory Name of the directory
25
     * 
26
     * @return "0" 
0 ignored issues
show
Documentation Bug introduced by
The doc comment "0" at position 0 could not be parsed: Unknown type name '"0"' at position 0 in "0".
Loading history...
27
     */
28
    function removeDirectory($directory) 
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
29
    {
30
        if (isset($directory)) {
31
            foreach (glob("{$directory}/*") as $file) {
32
                if (is_dir($file)) { 
33
                    $this->removeDirectory($file);
34
                } else {
35
                    unlink($file);
36
                }
37
            }
38
            rmdir($directory);
39
        }
40
    }
41
}
42
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...