Passed
Push — master ( 52bf93...8fa3ac )
by Kishan
02:14
created

Unlink_Directory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 8
dl 0
loc 20
rs 10
c 1
b 0
f 1
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A removeDirectory() 0 11 4
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 String 
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...