New answers tagged

1

I agree with the advice in slepic's answer. If you want to merely ensure that the file is an image, then you could ensure that the return value of exif_imagetype is not FALSE: return exif_imagetype($file->getRealPath()) !== FALSE; That way if more constants are ever added to the list of IMAGETYPE_* constants you would not need to update the ...


2

The method in question does not use $this therefore you might consider making it static. Further it is a private method, i dont know of which class, but consider making it a public method of its own class. The method accepts UploadedFile but it is only interested in the real path. As long as you keep it private it could be ok and simpler to call, but if ...


4

The loadData function looks just fine to me. I don't see a way it could be any more elegant given what it's doing. I do actually like the way you have separated reading the file and parsing it. That's the way to go. Your concern about "avoiding the IO monad" shouldn't be a concern. On the contrary, that's actually a "best practice", known as "pushing I/O ...


3

I know a directory looks like a tree structure. But you don't need to implement it as a tree. To me a file system is simply a map from name to object. class FileSystem { std::map<std::string, File>. fs; std::string currentDir; }; The artificial construct of directories is just a convenient way to simplify things for the ...


5

Why do the getters for Entry return const references? getEntryType, in particular, does not benefit at all from returning a reference since it just returns an enum value (which is the same size or smaller than what would be returned for the reference). getParentDirectory should be a const function. If the first three members of Entry are const members, ...


3

First, if you are using Python 3, you can use pathlib to make your life regarding paths a lot easier (especially if you want your scripts to work on both Windows and Linux). If you are not using Python 3 by now, well, you should. While your approach works (and could be made a bit shorter maybe using a complex RegEx), you might want to look into different ...


2

I think the modified date doesn't change when the file is moved to #Recycle area, so if the file is already older than 60 days, it will deleted the next time the script runs. I have observed that the 'change' date gets reset when moved to a new directory. Do a 'stat' or 'ls -lc' of the file before and after moving to different directory and you should see ...


Top 50 recent answers are included