From 2532fccaaddefb0573a070bfc357783ae84cbfc9 Mon Sep 17 00:00:00 2001 From: Pierre Grimaud Date: Mon, 23 Apr 2018 09:52:36 +0200 Subject: [PATCH] Set cacheDir mandatory --- README.md | 4 ++-- examples/medias.php | 2 +- src/Instagram/Storage/CacheManager.php | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 556f17f..d7def64 100644 --- a/README.md +++ b/README.md @@ -142,7 +142,7 @@ composer require pgrimaud/instagram-user-feed "^5.0" ## Usage of version ^5.0 ```php -$cache = new Instagram\Storage\CacheManager(); +$cache = new Instagram\Storage\CacheManager('/path/to/your/cache/folder'); $api = new Instagram\Api($cache); $api->setUserName('pgrimaud'); @@ -202,7 +202,7 @@ If you want to use paginate, retrieve `endCursor` from previous call and add it ```php // Initialization -$cache = new Instagram\Storage\CacheManager(); +$cache = new Instagram\Storage\CacheManager('/path/to/your/cache/folder'); $api = new Instagram\Api($cache); $api->setUserName('pgrimaud'); diff --git a/examples/medias.php b/examples/medias.php index be9647e..9f544f7 100644 --- a/examples/medias.php +++ b/examples/medias.php @@ -2,7 +2,7 @@ require __DIR__ . '/../vendor/autoload.php'; -$cache = new Instagram\Storage\CacheManager(); +$cache = new Instagram\Storage\CacheManager(__DIR__ . '/../cache/'); $api = new Instagram\Api($cache); $api->setUserName('pgrimaud'); diff --git a/src/Instagram/Storage/CacheManager.php b/src/Instagram/Storage/CacheManager.php index 9964481..6421750 100644 --- a/src/Instagram/Storage/CacheManager.php +++ b/src/Instagram/Storage/CacheManager.php @@ -13,11 +13,11 @@ class CacheManager /** * CacheManager constructor. - * @param null $cacheDir + * @param $cacheDir */ - public function __construct($cacheDir = null) + public function __construct($cacheDir) { - $this->cacheDir = $cacheDir ?: $this->cacheDir; + $this->cacheDir = $cacheDir; } /** @@ -26,7 +26,7 @@ public function __construct($cacheDir = null) */ private function getCacheFile($userId) { - return ($this->cacheDir ? $this->cacheDir : __DIR__ . '/../../../cache/') . $userId . '.cache'; + return $this->cacheDir . $userId . '.cache'; } /**