-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
178 changed files
with
2,119 additions
and
278 deletions.
There are no files selected for viewing
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
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
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
This file was deleted.
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
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
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,4 @@ | ||
parameters: | ||
level: 8 | ||
checkMissingIterableValueType: false | ||
checkGenericClassInNonGenericObjectType: false |
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 @@ | ||
coverage_clover: tests/_output/coverage.xml | ||
json_path: tests/_output/coveralls-upload.json | ||
service_name: travis-ci |
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,23 @@ | ||
language: php | ||
|
||
php: | ||
- 7.2 | ||
|
||
cache: | ||
directories: | ||
- vendor | ||
- $HOME/.composer/cache | ||
|
||
before_install: | ||
- pear channel-discover pear.phing.info | ||
- pear install phing/phing | ||
- phpenv rehash | ||
|
||
install: | ||
- composer install --no-interaction --prefer-dist | ||
|
||
script: | ||
- phing -f build.xml build -verbose | ||
|
||
after_success: | ||
- vendor/bin/php-coveralls |
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,62 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project name="jellyfish-cache-symfony" default="build"> | ||
<target name="codeception"> | ||
<exec executable="vendor/bin/codecept"> | ||
<arg value="run"/> | ||
<arg value="--report"/> | ||
<arg value="--html"/> | ||
<arg value="--xml"/> | ||
<arg value="--coverage"/> | ||
<arg value="--coverage-html"/> | ||
<arg value="--coverage-xml"/> | ||
</exec> | ||
</target> | ||
|
||
<target name="phpmd"> | ||
<exec executable="vendor/bin/phpmd"> | ||
<arg path="packages/"/> | ||
<arg value="xml"/> | ||
<arg value="design,cleancode,codesize"/> | ||
<arg value="--exclude"/> | ||
<arg value="EventServiceProvider.php,TransferServiceProvider.php,*Test.php"/> | ||
</exec> | ||
</target> | ||
|
||
<target name="phpcs"> | ||
<exec executable="vendor/bin/phpcs"> | ||
<arg value="--standard=PSR12"/> | ||
<arg path="src/"/> | ||
</exec> | ||
</target> | ||
|
||
<target name="phpcpd"> | ||
<exec executable="vendor/bin/phpcpd"> | ||
<arg path="src/"/> | ||
</exec> | ||
</target> | ||
|
||
<target name="phpstan"> | ||
<exec executable="vendor/bin/phpstan"> | ||
<arg value="analyse"/> | ||
<arg value="-c"/> | ||
<arg value="phpstan.neon"/> | ||
<arg path="src/"/> | ||
</exec> | ||
</target> | ||
|
||
<target name="build"> | ||
<phingcall target="build:analyse"/> | ||
<phingcall target="build:test"/> | ||
</target> | ||
|
||
<target name="build:analyse"> | ||
<phingcall target="phpcs"/> | ||
<phingcall target="phpmd"/> | ||
<phingcall target="phpcpd"/> | ||
<phingcall target="phpstan"/> | ||
</target> | ||
|
||
<target name="build:test"> | ||
<phingcall target="codeception"/> | ||
</target> | ||
</project> |
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,23 @@ | ||
namespace: cache-symfony | ||
|
||
suites: | ||
unit: | ||
path: . | ||
|
||
settings: | ||
shuffle: true | ||
lint: true | ||
bootstrap: _bootstrap.php | ||
|
||
paths: | ||
tests: tests | ||
output: tests/_output | ||
support: tests/_support | ||
data: tests/_data | ||
|
||
coverage: | ||
enabled: true | ||
include: | ||
- src/* | ||
exclude: | ||
- src/Jellyfish/CacheSymfony/CacheSymfonyServiceProvider.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,36 @@ | ||
{ | ||
"name": "jellyfish/cache-symfony", | ||
"description": "Jellyfish cache symfony bundle", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Daniel Rose", | ||
"email": "daniel-rose@gmx.de" | ||
} | ||
], | ||
"require": { | ||
"jellyfish/config": "dev-master", | ||
"jellyfish/cache": "dev-master", | ||
"symfony/cache": "~4.3.3" | ||
}, | ||
"require-dev": { | ||
"codeception/codeception": "~3.1.2", | ||
"mikey179/vfsstream": "~1.6.7", | ||
"php-coveralls/php-coveralls": "~2.1.0", | ||
"phpmd/phpmd": "~2.7.0", | ||
"phpstan/phpstan": "~0.12.0", | ||
"roave/security-advisories": "dev-master", | ||
"sebastian/phpcpd": "~4.1.0", | ||
"squizlabs/php_codesniffer": "~3.5.2" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Jellyfish\\CacheSymfony\\": "src/Jellyfish/CacheSymfony" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Jellyfish\\CacheSymfony\\": "tests/Jellyfish/CacheSymfony" | ||
} | ||
} | ||
} |
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,4 @@ | ||
parameters: | ||
level: 8 | ||
checkMissingIterableValueType: false | ||
checkGenericClassInNonGenericObjectType: false |
65 changes: 65 additions & 0 deletions
65
packages/cache-symfony/src/Jellyfish/CacheSymfony/Cache.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,65 @@ | ||
<?php | ||
|
||
namespace Jellyfish\CacheSymfony; | ||
|
||
use Jellyfish\Cache\CacheInterface; | ||
use Jellyfish\Cache\Exception\InvalidLifeTimeException; | ||
use Symfony\Component\Cache\Adapter\AbstractAdapter; | ||
|
||
class Cache implements CacheInterface | ||
{ | ||
/** | ||
* @var \Symfony\Component\Cache\Adapter\AbstractAdapter | ||
*/ | ||
protected $cacheAdapter; | ||
|
||
/** | ||
* @param \Symfony\Component\Cache\Adapter\AbstractAdapter $cacheAdapter | ||
*/ | ||
public function __construct(AbstractAdapter $cacheAdapter) | ||
{ | ||
$this->cacheAdapter = $cacheAdapter; | ||
} | ||
|
||
|
||
/** | ||
* @param string $key | ||
* | ||
* @return string|null | ||
*/ | ||
public function get(string $key): ?string | ||
{ | ||
$cacheItem = $this->cacheAdapter->getItem($key); | ||
|
||
if (!$cacheItem->isHit()) { | ||
return null; | ||
} | ||
|
||
return $cacheItem->get(); | ||
} | ||
|
||
/** | ||
* @param string $key | ||
* @param string $value | ||
* @param int|null $lifeTime | ||
* | ||
* @return \Jellyfish\Cache\CacheInterface | ||
* | ||
* @throws \Jellyfish\Cache\Exception\InvalidLifeTimeException | ||
*/ | ||
public function set(string $key, string $value, ?int $lifeTime = null): CacheInterface | ||
{ | ||
if ($lifeTime !== null && $lifeTime <= 0) { | ||
throw new InvalidLifeTimeException('The life time value must be greater then zero or null!'); | ||
} | ||
|
||
$cacheItem = $this->cacheAdapter->getItem($key); | ||
|
||
$cacheItem->set($value) | ||
->expiresAfter($lifeTime); | ||
|
||
$this->cacheAdapter->save($cacheItem); | ||
|
||
return $this; | ||
} | ||
} |
Oops, something went wrong.