@@ -54,35 +54,35 @@ |
||
54 | 54 | protected function configure() |
55 | 55 | { |
56 | 56 | $this |
57 | - ->setName('phpfastcache:set') |
|
58 | - ->setDescription('Set phpfastcache cache value') |
|
59 | - ->addArgument( |
|
57 | + ->setName('phpfastcache:set') |
|
58 | + ->setDescription('Set phpfastcache cache value') |
|
59 | + ->addArgument( |
|
60 | 60 | 'driver', |
61 | 61 | InputArgument::REQUIRED, |
62 | 62 | 'Cache name to clear' |
63 | - ) |
|
64 | - ->addArgument( |
|
63 | + ) |
|
64 | + ->addArgument( |
|
65 | 65 | 'key', |
66 | 66 | InputArgument::REQUIRED, |
67 | 67 | 'Cache key' |
68 | - ) |
|
69 | - ->addArgument( |
|
68 | + ) |
|
69 | + ->addArgument( |
|
70 | 70 | 'value', |
71 | 71 | InputArgument::REQUIRED, |
72 | 72 | 'Cache value' |
73 | - ) |
|
74 | - ->addArgument( |
|
73 | + ) |
|
74 | + ->addArgument( |
|
75 | 75 | 'ttl', |
76 | 76 | InputArgument::OPTIONAL, |
77 | 77 | 'Cache ttl (in second)' |
78 | - ) |
|
79 | - ->addOption( |
|
78 | + ) |
|
79 | + ->addOption( |
|
80 | 80 | 'auto-type-cast', |
81 | 81 | 'a', |
82 | 82 | InputOption::VALUE_OPTIONAL, |
83 | 83 | 'Allows to automatically type-cast the value of the cache item.', |
84 | 84 | 1 |
85 | - ) |
|
85 | + ) |
|
86 | 86 | ; |
87 | 87 | } |
88 | 88 |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $cacheTtl = $input->getArgument('ttl'); |
103 | 103 | $autoTypeCast = $input->getOption('auto-type-cast'); |
104 | 104 | |
105 | - if (\array_key_exists($driver, $caches[ 'drivers' ])) { |
|
105 | + if (\array_key_exists($driver, $caches['drivers'])) { |
|
106 | 106 | $io->section($driver); |
107 | 107 | $driverInstance = $this->phpfastcache->get($driver); |
108 | 108 | $cacheItem = $driverInstance->getItem($cacheKey); |
@@ -110,18 +110,18 @@ discard block |
||
110 | 110 | |
111 | 111 | $cacheItem->set($autoTypeCast ? $castedCacheValue : $cacheValue); |
112 | 112 | |
113 | - if($cacheTtl){ |
|
114 | - if(\is_numeric($cacheTtl)){ |
|
113 | + if ($cacheTtl) { |
|
114 | + if (\is_numeric($cacheTtl)) { |
|
115 | 115 | $cacheItem->expiresAfter($cacheTtl); |
116 | - }else{ |
|
116 | + } else { |
|
117 | 117 | $io->error(\sprintf('Invalid ttl value format "%s", must be a valid integer, aborting...', $cacheTtl)); |
118 | 118 | return; |
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
122 | - if($autoTypeCast && $castedCacheValue !== $cacheValue){ |
|
122 | + if ($autoTypeCast && $castedCacheValue !== $cacheValue) { |
|
123 | 123 | $io->success(\sprintf('Cache item "%s" set to "%s" for %d seconds (automatically type-casted to %s)', $cacheKey, $cacheValue, $cacheItem->getTtl(), \gettype($castedCacheValue))); |
124 | - }else{ |
|
124 | + } else { |
|
125 | 125 | $io->success(\sprintf('Cache item "%s" set to "%s" for %d seconds', $cacheKey, $cacheValue, $cacheItem->getTtl())); |
126 | 126 | } |
127 | 127 | |
@@ -137,24 +137,24 @@ discard block |
||
137 | 137 | */ |
138 | 138 | protected function autoTypeCast($string) |
139 | 139 | { |
140 | - if(\in_array($string, ['true', 'false'], true)){ |
|
140 | + if (\in_array($string, ['true', 'false'], true)) { |
|
141 | 141 | return $string === 'true'; |
142 | 142 | } |
143 | 143 | |
144 | - if($string === 'null'){ |
|
144 | + if ($string === 'null') { |
|
145 | 145 | return null; |
146 | 146 | } |
147 | 147 | |
148 | - if(\is_numeric($string)) |
|
148 | + if (\is_numeric($string)) |
|
149 | 149 | { |
150 | - if(\strpos($string, '.') !== false){ |
|
150 | + if (\strpos($string, '.') !== false) { |
|
151 | 151 | return (float) $string; |
152 | 152 | } |
153 | 153 | return (int) $string; |
154 | 154 | } |
155 | 155 | |
156 | 156 | $jsonArray = json_decode($string, true); |
157 | - if(json_last_error() === JSON_ERROR_NONE){ |
|
157 | + if (json_last_error() === JSON_ERROR_NONE) { |
|
158 | 158 | return (array) $jsonArray; |
159 | 159 | } |
160 | 160 |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | if($cacheTtl){ |
114 | 114 | if(\is_numeric($cacheTtl)){ |
115 | 115 | $cacheItem->expiresAfter($cacheTtl); |
116 | - }else{ |
|
116 | + } else{ |
|
117 | 117 | $io->error(\sprintf('Invalid ttl value format "%s", must be a valid integer, aborting...', $cacheTtl)); |
118 | 118 | return; |
119 | 119 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | |
122 | 122 | if($autoTypeCast && $castedCacheValue !== $cacheValue){ |
123 | 123 | $io->success(\sprintf('Cache item "%s" set to "%s" for %d seconds (automatically type-casted to %s)', $cacheKey, $cacheValue, $cacheItem->getTtl(), \gettype($castedCacheValue))); |
124 | - }else{ |
|
124 | + } else{ |
|
125 | 125 | $io->success(\sprintf('Cache item "%s" set to "%s" for %d seconds', $cacheKey, $cacheValue, $cacheItem->getTtl())); |
126 | 126 | } |
127 | 127 |