@@ -101,7 +101,7 @@ |
||
101 | 101 | if($cacheTtl){ |
102 | 102 | if(\is_numeric($cacheTtl)){ |
103 | 103 | $cacheItem->expiresAfter($cacheTtl); |
104 | - }else{ |
|
104 | + } else{ |
|
105 | 105 | $io->error(\sprintf('Invalid ttl value format "%s", must be a valid integer, aborting...', $cacheTtl)); |
106 | 106 | return; |
107 | 107 | } |
@@ -54,35 +54,35 @@ discard block |
||
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 | |
@@ -121,18 +121,18 @@ discard block |
||
121 | 121 | |
122 | 122 | if(!$autoTypeCast || $castedCacheValue === $cacheValue) { |
123 | 123 | $io->success(\sprintf( |
124 | - 'Cache item "%s" set to "%s" for %d seconds', |
|
125 | - $cacheKey, |
|
126 | - $cacheValue, |
|
127 | - $cacheItem->getTtl() |
|
124 | + 'Cache item "%s" set to "%s" for %d seconds', |
|
125 | + $cacheKey, |
|
126 | + $cacheValue, |
|
127 | + $cacheItem->getTtl() |
|
128 | 128 | )); |
129 | 129 | } else { |
130 | 130 | $io->success(\sprintf( |
131 | - 'Cache item "%s" set to "%s" for %d seconds (automatically type-casted to %s)', |
|
132 | - $cacheKey, |
|
133 | - $cacheValue, |
|
134 | - $cacheItem->getTtl(), |
|
135 | - \gettype($castedCacheValue) |
|
131 | + 'Cache item "%s" set to "%s" for %d seconds (automatically type-casted to %s)', |
|
132 | + $cacheKey, |
|
133 | + $cacheValue, |
|
134 | + $cacheItem->getTtl(), |
|
135 | + \gettype($castedCacheValue) |
|
136 | 136 | )); |
137 | 137 | } |
138 | 138 |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $cacheTtl = $input->getArgument('ttl'); |
103 | 103 | $autoTypeCast = (bool) $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,16 +110,16 @@ 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( |
124 | 124 | 'Cache item "%s" set to "%s" for %d seconds', |
125 | 125 | $cacheKey, |
@@ -148,24 +148,24 @@ discard block |
||
148 | 148 | */ |
149 | 149 | protected function autoTypeCast($string) |
150 | 150 | { |
151 | - if(\in_array(\strtolower($string), ['true', 'false'], true)){ |
|
151 | + if (\in_array(\strtolower($string), ['true', 'false'], true)) { |
|
152 | 152 | return $string === 'true'; |
153 | 153 | } |
154 | 154 | |
155 | - if(\strtolower($string) === 'null'){ |
|
155 | + if (\strtolower($string) === 'null') { |
|
156 | 156 | return null; |
157 | 157 | } |
158 | 158 | |
159 | - if(\is_numeric($string)) |
|
159 | + if (\is_numeric($string)) |
|
160 | 160 | { |
161 | - if(\strpos($string, '.') !== false){ |
|
161 | + if (\strpos($string, '.') !== false) { |
|
162 | 162 | return (float) $string; |
163 | 163 | } |
164 | 164 | return (int) $string; |
165 | 165 | } |
166 | 166 | |
167 | 167 | $jsonArray = json_decode($string, true); |
168 | - if(json_last_error() === JSON_ERROR_NONE){ |
|
168 | + if (json_last_error() === JSON_ERROR_NONE) { |
|
169 | 169 | return (array) $jsonArray; |
170 | 170 | } |
171 | 171 |