Code Duplication    Length = 25-25 lines in 2 locations

Core/Executor/FileExecutor.php 2 locations

@@ 129-153 (lines=25) @@
126
     * @return true
127
     * @throws \Exception
128
     */
129
    protected function copy($dsl, $context)
130
    {
131
        if (!isset($dsl['from']) || !isset($dsl['to'])) {
132
            throw new \Exception("Can not copy file: from or to missing");
133
        }
134
135
        $fileName = $this->referenceResolver->resolveReference($dsl['from']);
136
        if (!file_exists($fileName)) {
137
            throw new \Exception("Can not copy file '$fileName': file missing");
138
        }
139
140
        $this->setReferences($fileName, $dsl);
141
142
        $to = $this->referenceResolver->resolveReference($dsl['to']);
143
        $overwrite = isset($dsl['overwrite']) ? $overwrite = $dsl['overwrite'] : false;
144
        if (!$overwrite && file_exists($to)) {
145
            throw new \Exception("Can not copy file to '$to: file already exists");
146
        }
147
148
        if (!copy($fileName, $to)) {
149
            throw new \Exception("Can not copy file '$fileName' to '$to': operation failed");
150
        }
151
152
        return true;
153
    }
154
155
    /**
156
     * @param array $dsl
@@ 161-185 (lines=25) @@
158
     * @return true
159
     * @throws \Exception
160
     */
161
    protected function move($dsl, $context)
162
    {
163
        if (!isset($dsl['from']) || !isset($dsl['to'])) {
164
            throw new \Exception("Can not move file: from or to missing");
165
        }
166
167
        $fileName = $this->referenceResolver->resolveReference($dsl['from']);
168
        if (!file_exists($fileName)) {
169
            throw new \Exception("Can not move file '$fileName': file missing");
170
        }
171
172
        $this->setReferences($fileName, $dsl);
173
174
        $to = $this->referenceResolver->resolveReference($dsl['to']);
175
        $overwrite = isset($dsl['overwrite']) ? $overwrite = $dsl['overwrite'] : false;
176
        if (!$overwrite && file_exists($to)) {
177
            throw new \Exception("Can not move to '$to': file already exists");
178
        }
179
180
        if (!rename($fileName, $to)) {
181
            throw new \Exception("Can not move file '$fileName': operation failed");
182
        }
183
184
        return true;
185
    }
186
187
    /**
188
     * @param array $dsl