Fix race condition in PhpFileCache

Applied fix for possible race conditions from doctrine/cache#38 to `PhpFileCache` by extracting the code into the parent class to make sure both concrete caches create the cache file the same way. 

Also removes duplicated code and makes it more consistent. For example the `FilesystemCache` tried to create a missing path in `doSave` whereas `PhpFileCache` did not.

If you prefer two separate pull requests for this let me know.

Issue was originally reported in piwik/piwik#6873