I cannot find this in the docs, nor find this question raised anywhere else yet. I'm putting together some live tests for a driver, and it is throwing up questions like this.
A request to delete a directory - deleteDir() - that does not exist - what should the driver do? There is no API method to check if a directory exists, and there is no defined behavior when using has() when pointing at a file.
The deleteDir() method defines a boolean return, but does not state what that return value means. Should it return false if the directory does not exist? Then true if if did exist and was deleted? What about if it did exist but could not be deleted? Or surely if the directory does not exist in the first place, then asking for it to be deleted is just confirming that the state is what has been requested, so should return true? Then when should falseever be used? This method also does not define any exceptions that is expected to be thrown.
My current assumption is:
If the directory exists, then delete it (recursively). Return true.
If the directory does not exist, then job is already a good 'un. Return true.
If the underlying driver library fails to delete anything, then it will be throwing an exception. My guess is that the Omnipay driver should not try to handle that.
false is never actually returned. It works, or is already done, or an exception was thrown.
But that's just my assumption. Frameworks such as Laravel may have made different assumptions (and this, I believe, is where I am actually running into problems in a project).
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Question
I cannot find this in the docs, nor find this question raised anywhere else yet. I'm putting together some live tests for a driver, and it is throwing up questions like this.
A request to delete a directory -
deleteDir()
- that does not exist - what should the driver do? There is no API method to check if a directory exists, and there is no defined behavior when usinghas()
when pointing at a file.The
deleteDir()
method defines a boolean return, but does not state what that return value means. Should it returnfalse
if the directory does not exist? Thentrue
if if did exist and was deleted? What about if it did exist but could not be deleted? Or surely if the directory does not exist in the first place, then asking for it to be deleted is just confirming that the state is what has been requested, so should returntrue
? Then when shouldfalse
ever be used? This method also does not define any exceptions that is expected to be thrown.My current assumption is:
true
.true
.false
is never actually returned. It works, or is already done, or an exception was thrown.But that's just my assumption. Frameworks such as Laravel may have made different assumptions (and this, I believe, is where I am actually running into problems in a project).