-
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
0 parents
commit 6f769a2
Showing
20 changed files
with
643 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
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,27 @@ | ||
name: PHP Package Tests | ||
|
||
on: | ||
push: | ||
branches: [ main, develop ] | ||
pull_request: | ||
branches: [ main, develop ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
php-versions: ['8.1'] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Validate composer.json and composer.lock | ||
run: composer validate | ||
|
||
- name: Install dependencies | ||
run: composer install --prefer-dist --no-progress --no-suggest | ||
|
||
- name: Run tests | ||
run: vendor/bin/phpunit |
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,5 @@ | ||
/vendor | ||
composer.phar | ||
composer.lock | ||
.DS_Store | ||
.phpunit.result.cache |
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 @@ | ||
{"version":1,"defects":{"Tests\\Unit\\CacheTest::testCacheProvider":8},"times":{"Tests\\Unit\\CacheTest::testCacheProvider":0.036,"Tests\\Unit\\CacheTest::testCacheKeyMaker":0.001}} |
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,9 @@ | ||
preset: recommended | ||
|
||
risky: false | ||
|
||
linting: true | ||
|
||
finder: | ||
exclude: | ||
- "tests" |
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,56 @@ | ||
# Contributions are always welcome | ||
|
||
## Quick guide | ||
|
||
* Fork the repo. | ||
* Checkout the branch you want to make changes on: | ||
* Develop branch in 95% of the cases. | ||
* Install the dependencies: `composer install`. | ||
* Create branch such as: `feature-foo` or `fix-bar`. | ||
* Write some awesome code! | ||
* Add some tests, and ensure your code is PSR-2 compliant. | ||
* Submit your Pull Request | ||
|
||
## When opening a pull request | ||
You can do some things to increase the chance that your pull request is accepted the first time: | ||
|
||
* Submit one pull request per fix or feature. | ||
* If your changes are not up to date - rebase your branch on the parent branch. | ||
* Follow the conventions used in the project. | ||
* Remember about tests and documentation. | ||
|
||
## Naming Conventions | ||
|
||
* Use camelCase, not underscores, for variable, function and method names, arguments. | ||
* Use namespaces for all classes. | ||
* Prefix abstract classes with Abstract. | ||
* Suffix interfaces with Interface. | ||
* Suffix traits with Trait. | ||
* Suffix exceptions with Exception. | ||
* Suffix services with Service. | ||
* Use alphanumeric characters and underscores for file names. | ||
|
||
## PHPDoc | ||
|
||
We generally follow the doc standards of Laravel. | ||
|
||
``` | ||
/** | ||
* Register a binding with the container. | ||
* | ||
* @param string|array $abstract | ||
* @param \Closure|string|null $concrete | ||
* @param bool $shared | ||
* @return void | ||
*/ | ||
public function bind($abstract, $concrete = null, $shared = false) | ||
{ | ||
// | ||
} | ||
``` | ||
|
||
## Other general standards we follow | ||
* [PSR-1: Basic Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md) | ||
* [PSR-2: Coding Style Guide](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) | ||
* [PSR-4: Autoloading Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md) | ||
* [Symfony Coding Standards](http://symfony.com/doc/current/contributing/code/standards.html) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Matt Lantz | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,10 @@ | ||
# Grafite Support License | ||
|
||
The MIT License (MIT) | ||
Copyright (c) Grafite Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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,58 @@ | ||
![Grafite Cache](GrafiteCache-banner.png) | ||
|
||
**Cache** - SQLite based cache driver with some fancy extras like tagging and encryption etc. | ||
|
||
[![Build Status](https://github.com/GrafiteInc/Cache/workflows/PHP%20Package%20Tests/badge.svg?branch=main)](https://github.com/GrafiteInc/Cache/actions?query=workflow%3A%22PHP+Package+Tests%22) | ||
[![Maintainability](https://api.codeclimate.com/v1/badges/a90e41bd64d41508ef0e/maintainability)](https://codeclimate.com/github/GrafiteInc/Cache/maintainability) | ||
[![Packagist](https://img.shields.io/packagist/dt/grafite/cache.svg)](https://packagist.org/packages/grafite/cache) | ||
[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://packagist.org/packages/grafite/cache) | ||
|
||
The Cache package an SQLite based cache driver with some fancy extras like tagging and encryption. | ||
|
||
##### Author(s): | ||
* [Matt Lantz](https://github.com/mlantz) ([@mattylantz](http://twitter.com/mattylantz), mattlantz at gmail dot com) | ||
|
||
## Requirements | ||
|
||
1. PHP 8.2+ | ||
|
||
## Compatibility and Support | ||
|
||
| Laravel Version | Package Tag | Supported | | ||
|-----------------|-------------|-----------| | ||
| ^11.x | 1.x | yes | | ||
|
||
### Installation | ||
|
||
Start a new Laravel project: | ||
```php | ||
composer create-project laravel/laravel your-project-name | ||
``` | ||
|
||
Then run the following to add Support | ||
```php | ||
composer require "grafite/cache" | ||
``` | ||
|
||
Append to the `cache.php` config file in the stores array: | ||
```php | ||
'sqlite' => [ | ||
'driver' => 'sqlite', | ||
'table' => 'cache', | ||
'database' => env('CACHE_DATABASE', database_path('cache.sqlite')), | ||
'prefix' => '', | ||
], | ||
``` | ||
|
||
## Documentation | ||
|
||
[https://docs.grafite.ca/utilities/cache](https://docs.grafite.ca/utilities/cache) | ||
|
||
## License | ||
Support is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) | ||
|
||
### Bug Reporting and Feature Requests | ||
Please add as many details as possible regarding submission of issues and feature requests | ||
|
||
### Disclaimer | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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 @@ | ||
# Change Log - Grafite Cache | ||
All notable changes to this project will be documented in this file. | ||
This project adheres to [Semantic Versioning](http://semver.org/). | ||
---- |
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,55 @@ | ||
{ | ||
"name": "grafite/cache", | ||
"description": "An SQLite based cache with some extra features.", | ||
"license": "MIT", | ||
"keywords": [ | ||
"Laravel" | ||
], | ||
"authors": [ | ||
{ | ||
"name": "Matt Lantz", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"php": "^8.2", | ||
"illuminate/support": "^11.0", | ||
"illuminate/collections": "^11.0" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^10.0", | ||
"mockery/mockery": "^1.0", | ||
"laravel/pint": "^1.10", | ||
"orchestra/testbench": "^8.0|^9.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Grafite\\Cache\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Tests\\": "tests/" | ||
} | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"Grafite\\Cache\\CacheProvider" | ||
] | ||
} | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"scripts": { | ||
"check-style": "vendor/bin/pint --test", | ||
"fix-style": "vendor/bin/pint", | ||
"insights": "vendor/bin/phpinsights", | ||
"test": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-clover clover.xml && php coverage-checker.php clover.xml 50" | ||
}, | ||
"config": { | ||
"allow-plugins": { | ||
"dealerdirect/phpcodesniffer-composer-installer": true | ||
} | ||
} | ||
} |
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,33 @@ | ||
<?php | ||
|
||
// coverage-checker.php | ||
$inputFile = $argv[1]; | ||
$percentage = min(100, max(0, (int) $argv[2])); | ||
|
||
if (! file_exists($inputFile)) { | ||
throw new InvalidArgumentException('Invalid input file provided'); | ||
} | ||
|
||
if (! $percentage) { | ||
throw new InvalidArgumentException('An integer checked percentage must be given as second parameter'); | ||
} | ||
|
||
$xml = new SimpleXMLElement(file_get_contents($inputFile)); | ||
$metrics = $xml->xpath('//metrics'); | ||
$totalElements = 0; | ||
$checkedElements = 0; | ||
|
||
foreach ($metrics as $metric) { | ||
$totalElements += (int) $metric['elements']; | ||
$checkedElements += (int) $metric['coveredelements']; | ||
} | ||
|
||
$coverage = ($checkedElements / $totalElements) * 100; | ||
|
||
if ($coverage < $percentage) { | ||
echo 'Code coverage is '.$coverage.'%, which is below the accepted '.$percentage.'%'.PHP_EOL; | ||
|
||
exit(1); | ||
} | ||
|
||
echo 'Code coverage is '.$coverage.'% - OK!'.PHP_EOL; |
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,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true" cacheDirectory=".phpunit.cache"> | ||
<testsuites> | ||
<testsuite name="Unit"> | ||
<directory suffix="Test.php">./tests/Unit/</directory> | ||
</testsuite> | ||
</testsuites> | ||
<coverage/> | ||
<source> | ||
<include> | ||
<directory suffix=".php">./src</directory> | ||
</include> | ||
</source> | ||
<php> | ||
<server name="APP_ENV" value="testing"/> | ||
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/> | ||
<server name="CACHE_DRIVER" value="sqlite"/> | ||
</php> | ||
</phpunit> |
Oops, something went wrong.