Skip to content

Commit

Permalink
Merge 8880336 into dbf0477
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-rose committed Oct 27, 2020
2 parents dbf0477 + 8880336 commit 6ef23b9
Show file tree
Hide file tree
Showing 178 changed files with 2,119 additions and 278 deletions.
6 changes: 3 additions & 3 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
<target name="phpstan">
<exec executable="vendor/bin/phpstan">
<arg value="analyse"/>
<arg value="--level"/>
<arg value="7"/>
<arg value="-c"/>
<arg value="phpstan.neon"/>
<arg path="packages/*/src/"/>
</exec>
</target>
Expand All @@ -59,4 +59,4 @@
<target name="build:test">
<phingcall target="codeception"/>
</target>
</project>
</project>
5 changes: 5 additions & 0 deletions codeception.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
include:
- packages/application/
- packages/cache/
- packages/cache-symfony/
- packages/config/
- packages/event/
- packages/event-cache/
- packages/event-log/
- packages/feed/
- packages/finder/
Expand All @@ -23,6 +26,8 @@ include:
- packages/serializer/
- packages/serializer-symfony/
- packages/transfer/
- packages/uuid/
- packages/uuid-ramsey/

settings:
shuffle: true
Expand Down
19 changes: 15 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"phpdocumentor/reflection-docblock": "~4.3.2",
"pimple/pimple": "~3.2.3",
"predis/predis": "~1.1.1",
"ramsey/uuid": "~4.1.0",
"symfony/cache": "~4.3.3",
"symfony/console": "~4.3.3",
"symfony/filesystem": "~4.3.3",
"symfony/lock": "~4.3.3",
Expand All @@ -38,8 +40,7 @@
"mikey179/vfsstream": "~1.6.7",
"php-coveralls/php-coveralls": "~2.1.0",
"phpmd/phpmd": "~2.7.0",
"phpro/grumphp": "~0.16.1",
"phpstan/phpstan": "~0.11.2",
"phpstan/phpstan": "~0.12.0",
"roave/security-advisories": "dev-master as 1.0.0",
"sebastian/phpcpd": "~4.1.0",
"sllh/composer-versions-check": "~2.0.3",
Expand All @@ -51,8 +52,11 @@
"autoload": {
"psr-4": {
"Jellyfish\\Application\\": "packages/application/src/Jellyfish/Application",
"Jellyfish\\Cache\\": "packages/cache/src/Jellyfish/Cache",
"Jellyfish\\CacheSymfony\\": "packages/cache-symfony/src/Jellyfish/CacheSymfony",
"Jellyfish\\Config\\": "packages/config/src/Jellyfish/Config",
"Jellyfish\\Event\\": "packages/event/src/Jellyfish/Event",
"Jellyfish\\EventCache\\": "packages/event-cache/src/Jellyfish/EventCache",
"Jellyfish\\EventLog\\": "packages/event-log/src/Jellyfish/EventLog",
"Jellyfish\\Feed\\": "packages/feed/src/Jellyfish/Feed",
"Jellyfish\\Filesystem\\": "packages/filesystem/src/Jellyfish/Filesystem",
Expand All @@ -74,14 +78,19 @@
"Jellyfish\\Scheduler\\": "packages/scheduler/src/Jellyfish/Scheduler",
"Jellyfish\\Serializer\\": "packages/serializer/src/Jellyfish/Serializer",
"Jellyfish\\SerializerSymfony\\": "packages/serializer-symfony/src/Jellyfish/SerializerSymfony",
"Jellyfish\\Transfer\\": "packages/transfer/src/Jellyfish/Transfer"
"Jellyfish\\Transfer\\": "packages/transfer/src/Jellyfish/Transfer",
"Jellyfish\\Uuid\\": "packages/uuid/src/Jellyfish/Uuid",
"Jellyfish\\UuidRamsey\\": "packages/uuid-ramsey/src/Jellyfish/UuidRamsey"
}
},
"autoload-dev": {
"psr-4": {
"Jellyfish\\Application\\": "packages/application/tests/Jellyfish/Application",
"Jellyfish\\Cache\\": "packages/cache/tests/Jellyfish/Cache",
"Jellyfish\\CacheSymfony\\": "packages/cache-symfony/tests/Jellyfish/CacheSymfony",
"Jellyfish\\Config\\": "packages/config/tests/Jellyfish/Config",
"Jellyfish\\Event\\": "packages/event/tests/Jellyfish/Event",
"Jellyfish\\EventCache\\": "packages/event-cache/tests/Jellyfish/EventCache",
"Jellyfish\\EventLog\\": "packages/event-log/tests/Jellyfish/EventLog",
"Jellyfish\\Feed\\": "packages/feed/tests/Jellyfish/Feed",
"Jellyfish\\Filesystem\\": "packages/filesystem/tests/Jellyfish/Filesystem",
Expand All @@ -100,7 +109,9 @@
"Jellyfish\\Redis\\": "packages/redis/tests/Jellyfish/Redis",
"Jellyfish\\Scheduler\\": "packages/scheduler/tests/Jellyfish/Scheduler",
"Jellyfish\\SerializerSymfony\\": "packages/serializer-symfony/tests/Jellyfish/SerializerSymfony",
"Jellyfish\\Transfer\\": "packages/transfer/tests/Jellyfish/Transfer"
"Jellyfish\\Transfer\\": "packages/transfer/tests/Jellyfish/Transfer",
"Jellyfish\\Uuid\\": "packages/uuid/tests/Jellyfish/Uuid",
"Jellyfish\\UuidRamsey\\": "packages/uuid-ramsey/tests/Jellyfish/UuidRamsey"
}
}
}
25 changes: 0 additions & 25 deletions grumphp.yml

This file was deleted.

6 changes: 3 additions & 3 deletions packages/application/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
<target name="phpstan">
<exec executable="vendor/bin/phpstan">
<arg value="analyse"/>
<arg value="--level"/>
<arg value="7"/>
<arg value="-c"/>
<arg value="phpstan.neon"/>
<arg path="src/"/>
</exec>
</target>
Expand All @@ -59,4 +59,4 @@
<target name="build:test">
<phingcall target="codeception"/>
</target>
</project>
</project>
5 changes: 2 additions & 3 deletions packages/application/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
"mikey179/vfsstream": "~1.6.7",
"php-coveralls/php-coveralls": "~2.1.0",
"phpmd/phpmd": "~2.7.0",
"phpro/grumphp": "~0.16.1",
"phpstan/phpstan": "~0.11.2",
"phpstan/phpstan": "~0.12.0",
"roave/security-advisories": "dev-master",
"sebastian/phpcpd": "~4.1.0",
"squizlabs/php_codesniffer": "~3.5.2"
Expand All @@ -38,4 +37,4 @@
"bin": [
"bin/console"
]
}
}
4 changes: 4 additions & 0 deletions packages/application/phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parameters:
level: 8
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
3 changes: 3 additions & 0 deletions packages/cache-symfony/.coveralls.yml
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
23 changes: 23 additions & 0 deletions packages/cache-symfony/.travis.yml
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
62 changes: 62 additions & 0 deletions packages/cache-symfony/build.xml
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>
23 changes: 23 additions & 0 deletions packages/cache-symfony/codeception.yml
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
36 changes: 36 additions & 0 deletions packages/cache-symfony/composer.json
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"
}
}
}
4 changes: 4 additions & 0 deletions packages/cache-symfony/phpstan.neon
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 packages/cache-symfony/src/Jellyfish/CacheSymfony/Cache.php
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;
}
}

0 comments on commit 6ef23b9

Please sign in to comment.