Code Duplication    Length = 125-125 lines in 2 locations

php5/Objects/LinkObject.inc 1 location

@@ 29-153 (lines=125) @@
26
use HOWI3\libhowi\Filesystem\php5\TraitForSharedMethods;
27
use HOWI3\libhowi\Filesystem\Commons\ObjectInterfaces\LinkInterface;
28
29
class LinkObject implements LinkInterface
30
{
31
    
32
    use TraitForSharedMethods;
33
34
    /**
35
     *
36
     * {@inheritDoc}
37
     *
38
     */
39
    public function symlink($target = false, $link = false)
40
    {
41
        if (empty($target) || empty($link))
42
            return false;
43
        
44
        $target = $this->makeAbsolute($target);
45
        $link = $this->makeAbsolute($link);
46
        
47
        if (! file_exists($target) || file_exists($link))
48
            return false;
49
        
50
        return symlink($target, $link);
51
    }
52
53
    /**
54
     *
55
     * {@inheritDoc}
56
     *
57
     */
58
    public function hardlink($target = false, $link = false)
59
    {
60
        if (empty($target) || empty($link))
61
            return false;
62
        
63
        $target = $this->makeAbsolute($target);
64
        $link = $this->makeAbsolute($link);
65
        
66
        if (! file_exists($target) || is_dir($target) || file_exists($link))
67
            return false;
68
        
69
        return link($target, $link);
70
    }
71
72
    /**
73
     *
74
     * {@inheritDoc}
75
     *
76
     */
77
    public function lstat($link = false)
78
    {
79
        if (empty($link))
80
            return false;
81
        $link = $this->makeAbsolute($link);
82
        return @lstat($link);
83
    }
84
85
    /**
86
     *
87
     * {@inheritDoc}
88
     *
89
     */
90
    public function lstatDiff($link = false)
91
    {
92
        if (empty($link))
93
            return false;
94
        $link = $this->makeAbsolute($link);
95
        return array_diff(stat($link), lstat($link));
96
    }
97
98
    /**
99
     *
100
     * {@inheritDoc}
101
     *
102
     */
103
    public function readlink($link = false)
104
    {
105
        if (empty($link))
106
            return false;
107
        
108
        $link = $this->makeAbsolute($link);
109
        return readlink($link);
110
    }
111
112
    /**
113
     *
114
     * {@inheritDoc}
115
     *
116
     */
117
    public function lchgrp($link = false, $group = false)
118
    {
119
        if (empty($link))
120
            return false;
121
        
122
        $link = $this->makeAbsolute($link);
123
        return @lchgrp($link, $group);
124
    }
125
126
    /**
127
     *
128
     * {@inheritDoc}
129
     *
130
     */
131
    public function lchown($link = false, $group = false)
132
    {
133
        if (empty($link))
134
            return false;
135
        
136
        $link = $this->makeAbsolute($link);
137
        return @lchown($link, $group);
138
    }
139
140
    /**
141
     *
142
     * {@inheritDoc}
143
     *
144
     */
145
    public function linkinfo($link = false)
146
    {
147
        if (empty($link))
148
            return false;
149
        
150
        $link = $this->makeAbsolute($link);
151
        return linkinfo($link);
152
    }
153
}
154

php7/Objects/LinkObject.inc 1 location

@@ 29-153 (lines=125) @@
26
use HOWI3\libhowi\Filesystem\php7\TraitForSharedMethods;
27
use HOWI3\libhowi\Filesystem\Commons\ObjectInterfaces\LinkInterface;
28
29
class LinkObject implements LinkInterface
30
{
31
    
32
    use TraitForSharedMethods;
33
34
    /**
35
     *
36
     * {@inheritDoc}
37
     *
38
     */
39
    public function symlink($target = false, $link = false)
40
    {
41
        if (empty($target) || empty($link))
42
            return false;
43
        
44
        $target = $this->makeAbsolute($target);
45
        $link = $this->makeAbsolute($link);
46
        
47
        if (! file_exists($target) || file_exists($link))
48
            return false;
49
        
50
        return symlink($target, $link);
51
    }
52
53
    /**
54
     *
55
     * {@inheritDoc}
56
     *
57
     */
58
    public function hardlink($target = false, $link = false)
59
    {
60
        if (empty($target) || empty($link))
61
            return false;
62
        
63
        $target = $this->makeAbsolute($target);
64
        $link = $this->makeAbsolute($link);
65
        
66
        if (! file_exists($target) || is_dir($target) || file_exists($link))
67
            return false;
68
        
69
        return link($target, $link);
70
    }
71
72
    /**
73
     *
74
     * {@inheritDoc}
75
     *
76
     */
77
    public function lstat($link = false)
78
    {
79
        if (empty($link))
80
            return false;
81
        $link = $this->makeAbsolute($link);
82
        return @lstat($link);
83
    }
84
85
    /**
86
     *
87
     * {@inheritDoc}
88
     *
89
     */
90
    public function lstatDiff($link = false)
91
    {
92
        if (empty($link))
93
            return false;
94
        $link = $this->makeAbsolute($link);
95
        return array_diff(stat($link), lstat($link));
96
    }
97
98
    /**
99
     *
100
     * {@inheritDoc}
101
     *
102
     */
103
    public function readlink($link = false)
104
    {
105
        if (empty($link))
106
            return false;
107
        
108
        $link = $this->makeAbsolute($link);
109
        return readlink($link);
110
    }
111
112
    /**
113
     *
114
     * {@inheritDoc}
115
     *
116
     */
117
    public function lchgrp($link = false, $group = false)
118
    {
119
        if (empty($link))
120
            return false;
121
        
122
        $link = $this->makeAbsolute($link);
123
        return @lchgrp($link, $group);
124
    }
125
126
    /**
127
     *
128
     * {@inheritDoc}
129
     *
130
     */
131
    public function lchown($link = false, $group = false)
132
    {
133
        if (empty($link))
134
            return false;
135
        
136
        $link = $this->makeAbsolute($link);
137
        return @lchown($link, $group);
138
    }
139
140
    /**
141
     *
142
     * {@inheritDoc}
143
     *
144
     */
145
    public function linkinfo($link = false)
146
    {
147
        if (empty($link))
148
            return false;
149
        
150
        $link = $this->makeAbsolute($link);
151
        return linkinfo($link);
152
    }
153
}
154