-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
16,503 changed files
with
1,412,512 additions
and
3,496 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
872 changes: 663 additions & 209 deletions
872
app-lib/php/classes/3rd-party/google-api/composer.lock
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../squizlabs/php_codesniffer/scripts/phpcbf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../squizlabs/php_codesniffer/scripts/phpcs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../phpunit/phpunit/phpunit |
3 changes: 3 additions & 0 deletions
3
app-lib/php/classes/3rd-party/google-api/vendor/cache/adapter-common/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/vendor/ | ||
composer.lock | ||
|
288 changes: 288 additions & 0 deletions
288
app-lib/php/classes/3rd-party/google-api/vendor/cache/adapter-common/AbstractCachePool.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,288 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of php-cache organization. | ||
* | ||
* (c) 2015-2015 Aaron Scherer <aequasi@gmail.com>, Tobias Nyholm <tobias.nyholm@gmail.com> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Cache\Adapter\Common; | ||
|
||
use Cache\Adapter\Common\Exception\CacheException; | ||
use Cache\Adapter\Common\Exception\CachePoolException; | ||
use Cache\Adapter\Common\Exception\InvalidArgumentException; | ||
use Psr\Cache\CacheItemInterface; | ||
use Psr\Cache\CacheItemPoolInterface; | ||
use Psr\Log\LoggerAwareInterface; | ||
use Psr\Log\LoggerInterface; | ||
|
||
/** | ||
* @author Aaron Scherer <aequasi@gmail.com> | ||
* @author Tobias Nyholm <tobias.nyholm@gmail.com> | ||
*/ | ||
abstract class AbstractCachePool implements CacheItemPoolInterface, LoggerAwareInterface | ||
{ | ||
/** | ||
* @type LoggerInterface | ||
*/ | ||
private $logger; | ||
|
||
/** | ||
* @type CacheItemInterface[] deferred | ||
*/ | ||
protected $deferred = []; | ||
|
||
/** | ||
* @param CacheItemInterface $item | ||
* @param int|null $ttl seconds from now | ||
* | ||
* @return bool true if saved | ||
*/ | ||
abstract protected function storeItemInCache(CacheItemInterface $item, $ttl); | ||
|
||
/** | ||
* Fetch an object from the cache implementation. | ||
* | ||
* @param string $key | ||
* | ||
* @return array with [isHit, value, [tags]] | ||
*/ | ||
abstract protected function fetchObjectFromCache($key); | ||
|
||
/** | ||
* Clear all objects from cache. | ||
* | ||
* @return bool false if error | ||
*/ | ||
abstract protected function clearAllObjectsFromCache(); | ||
|
||
/** | ||
* Remove one object from cache. | ||
* | ||
* @param string $key | ||
* | ||
* @return bool | ||
*/ | ||
abstract protected function clearOneObjectFromCache($key); | ||
|
||
/** | ||
* Make sure to commit before we destruct. | ||
*/ | ||
public function __destruct() | ||
{ | ||
$this->commit(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getItem($key) | ||
{ | ||
$this->validateKey($key); | ||
if (isset($this->deferred[$key])) { | ||
$item = $this->deferred[$key]; | ||
|
||
return is_object($item) ? clone $item : $item; | ||
} | ||
|
||
$func = function () use ($key) { | ||
try { | ||
return $this->fetchObjectFromCache($key); | ||
} catch (\Exception $e) { | ||
$this->handleException($e, __FUNCTION__); | ||
} | ||
}; | ||
|
||
return new CacheItem($key, $func); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getItems(array $keys = []) | ||
{ | ||
$items = []; | ||
foreach ($keys as $key) { | ||
$items[$key] = $this->getItem($key); | ||
} | ||
|
||
return $items; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function hasItem($key) | ||
{ | ||
try { | ||
return $this->getItem($key)->isHit(); | ||
} catch (\Exception $e) { | ||
$this->handleException($e, __FUNCTION__); | ||
} | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function clear() | ||
{ | ||
// Clear the deferred items | ||
$this->deferred = []; | ||
|
||
try { | ||
return $this->clearAllObjectsFromCache(); | ||
} catch (\Exception $e) { | ||
$this->handleException($e, __FUNCTION__); | ||
} | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function deleteItem($key) | ||
{ | ||
try { | ||
return $this->deleteItems([$key]); | ||
} catch (\Exception $e) { | ||
$this->handleException($e, __FUNCTION__); | ||
} | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function deleteItems(array $keys) | ||
{ | ||
$deleted = true; | ||
foreach ($keys as $key) { | ||
$this->validateKey($key); | ||
|
||
// Delete form deferred | ||
unset($this->deferred[$key]); | ||
|
||
if (!$this->clearOneObjectFromCache($key)) { | ||
$deleted = false; | ||
} | ||
} | ||
|
||
return $deleted; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function save(CacheItemInterface $item) | ||
{ | ||
$timeToLive = null; | ||
if ($item instanceof HasExpirationDateInterface) { | ||
if (null !== $expirationDate = $item->getExpirationDate()) { | ||
$timeToLive = $expirationDate->getTimestamp() - time(); | ||
|
||
if ($timeToLive < 0) { | ||
return $this->deleteItem($item->getKey()); | ||
} | ||
} | ||
} | ||
|
||
try { | ||
return $this->storeItemInCache($item, $timeToLive); | ||
} catch (\Exception $e) { | ||
$this->handleException($e, __FUNCTION__); | ||
} | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function saveDeferred(CacheItemInterface $item) | ||
{ | ||
$this->deferred[$item->getKey()] = $item; | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function commit() | ||
{ | ||
$saved = true; | ||
foreach ($this->deferred as $item) { | ||
if (!$this->save($item)) { | ||
$saved = false; | ||
} | ||
} | ||
$this->deferred = []; | ||
|
||
return $saved; | ||
} | ||
|
||
/** | ||
* @param string $key | ||
* | ||
* @throws InvalidArgumentException | ||
*/ | ||
protected function validateKey($key) | ||
{ | ||
if (!is_string($key)) { | ||
throw new InvalidArgumentException(sprintf( | ||
'Cache key must be string, "%s" given', gettype($key) | ||
)); | ||
} | ||
|
||
if (preg_match('|[\{\}\(\)/\\\@\:]|', $key)) { | ||
throw new InvalidArgumentException(sprintf( | ||
'Invalid key: "%s". The key contains one or more characters reserved for future extension: {}()/\@:', | ||
$key | ||
)); | ||
} | ||
} | ||
|
||
/** | ||
* @param LoggerInterface $logger | ||
*/ | ||
public function setLogger(LoggerInterface $logger) | ||
{ | ||
$this->logger = $logger; | ||
} | ||
|
||
/** | ||
* Logs with an arbitrary level if the logger exists. | ||
* | ||
* @param mixed $level | ||
* @param string $message | ||
* @param array $context | ||
*/ | ||
protected function log($level, $message, array $context = []) | ||
{ | ||
if ($this->logger !== null) { | ||
$this->logger->log($level, $message, $context); | ||
} | ||
} | ||
|
||
/** | ||
* Log exception and rethrow it. | ||
* | ||
* @param \Exception $e | ||
* @param string $function | ||
* | ||
* @throws CachePoolException | ||
*/ | ||
private function handleException(\Exception $e, $function) | ||
{ | ||
$level = 'alert'; | ||
if ($e instanceof InvalidArgumentException) { | ||
$level = 'warning'; | ||
} | ||
|
||
$this->log($level, $e->getMessage(), ['exception' => $e]); | ||
if (!$e instanceof CacheException) { | ||
$e = new CachePoolException(sprintf('Exception thrown when executing "%s". ', $function), 0, $e); | ||
} | ||
|
||
throw $e; | ||
} | ||
} |
Oops, something went wrong.