-
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 8240ff7
Showing
16 changed files
with
444 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,15 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = tab | ||
indent_size = 4 | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.{yml,yaml,json}] | ||
indent_size = 2 |
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,8 @@ | ||
# Ignore all test and documentation with "export-ignore". | ||
/.gitattributes export-ignore | ||
/.github export-ignore | ||
/.gitignore export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/phpcs.xml export-ignore | ||
/tests export-ignore | ||
/.editorconfig export-ignore |
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,42 @@ | ||
name: tests | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php: [8.2, 8.1, 8.0] | ||
laravel: ["^10.0", "^9.0"] | ||
dependency-version: [prefer-lowest, prefer-stable] | ||
exclude: | ||
- laravel: "^10.0" | ||
php: 8.0 | ||
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.composer/cache/files | ||
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, mysql, mysqli, pdo_mysql, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo | ||
coverage: none | ||
|
||
- name: Install dependencies | ||
uses: ramsey/composer-install@v2 | ||
|
||
- name: Execute tests | ||
run: composer test |
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,28 @@ | ||
name: "Update Changelog" | ||
|
||
on: | ||
release: | ||
types: [released] | ||
|
||
jobs: | ||
update: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: master | ||
|
||
- name: Update Changelog | ||
uses: stefanzweifel/changelog-updater-action@v1 | ||
with: | ||
latest-version: ${{ github.event.release.name }} | ||
release-notes: ${{ github.event.release.body }} | ||
|
||
- name: Commit updated CHANGELOG | ||
uses: stefanzweifel/git-auto-commit-action@v4.15.4 | ||
with: | ||
branch: master | ||
commit_message: Update CHANGELOG | ||
file_pattern: CHANGELOG.md |
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 | ||
.idea | ||
composer.lock |
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,7 @@ | ||
# Changelog | ||
|
||
All notable changes to `syberisle/laravel-castable-archive` will be documented in this file | ||
|
||
## 0.0.0 - 2024-03-17 | ||
|
||
Initial Release |
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,17 @@ | ||
# Contributing | ||
|
||
Contributions are **welcome** and will be fully **credited**. | ||
|
||
We accept contributions via Pull Requests on [Github](https://github.com/syberisle/laravel-castable-archive). | ||
|
||
## Pull Requests | ||
|
||
- **[SyberIsle Coding Standard](https://github.com/SyberIsle/coding-standards)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer). | ||
|
||
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. | ||
|
||
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). | ||
|
||
- **Create feature branches** - Don't ask us to pull from your master branch. | ||
|
||
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. |
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 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2024 SyberIsle, LLC. | ||
|
||
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,49 @@ | ||
# Laravel Model attribute to de/compress the value | ||
|
||
[![Latest Version on Packagist](https://img.shields.io/packagist/v/syberisle/laravel-castable-archive.svg?style=flat-square)](https://packagist.org/packages/syberisle/laravel-castable-archive) | ||
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/syberisle/laravel-castable-archive/run-tests.yml?branch=main&label=Tests)](https://github.com/syberisle/laravel-castable-archive/actions/workflows/tests.yml) | ||
[![Total Downloads](https://img.shields.io/packagist/dt/syberisle/laravel-castable-archive.svg?style=flat-square)](https://packagist.org/packages/syberisle/laravel-castable-archive) | ||
|
||
This package allows you to cast a model attribute as a compressed value using either gzip or bzip. | ||
|
||
Available Casts: | ||
- `SyberIsle\Laravel\Cast\Archive\BzArchive` | ||
- `SyberIsle\Laravel\Cast\Archive\GzArchive` | ||
|
||
## Installation | ||
|
||
```shell | ||
composer install syberisle/laravel-castable-archive | ||
``` | ||
|
||
## Usage | ||
|
||
```php | ||
use SyberIsle\Laravel\Cast\Archive; | ||
|
||
class MyModel | ||
{ | ||
protected $casts = [ | ||
'field_name' => Archive\GzArchive::class | ||
]; | ||
} | ||
|
||
$model->field_name = 'kakaw' // raw attribute = b"ËNÌN,\x07\x00" | ||
$value = $model->field_name; // = 'kakaw' | ||
``` | ||
|
||
## Changelog | ||
|
||
Please see [CHANGELOG](CHANGELOG.md) for more information about recent changes. | ||
|
||
## Contributing | ||
|
||
Please see [CONTRIBUTING](CONTRIBUTING.md) for details. | ||
|
||
## Security | ||
|
||
If you've found a bug regarding security please report it via the security tab of this repository. | ||
|
||
## License | ||
|
||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information. |
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,53 @@ | ||
{ | ||
"name": "syberisle/laravel-castable-archive", | ||
"description": "Tool for casting a model field as bzip or gzip", | ||
"license": "MIT", | ||
"keywords": [ | ||
"laravel", | ||
"model cast", | ||
"gzip", | ||
"bzip" | ||
], | ||
"authors": [ | ||
{ | ||
"name": "David Lundgren", | ||
"email": "dlundgren@syberisle.com", | ||
"role": "Developer" | ||
} | ||
], | ||
"homepage": "https://github.com/syberisle/laravel-castable-archive", | ||
"require": { | ||
"php": "^8.0", | ||
"ext-bz2": "*", | ||
"ext-zlib": "*", | ||
"illuminate/contracts": "^9.28 || ^10.0 || ^11.0" | ||
}, | ||
"require-dev": { | ||
"nunomaduro/collision": "^6.2", | ||
"orchestra/testbench": "^7.7 || ^8.0", | ||
"phpstan/phpstan": "^1.8", | ||
"phpunit/phpunit": "^9.5.24", | ||
"squizlabs/php_codesniffer": "^3.9", | ||
"syberisle/coding-standards": "^2.0" | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"autoload": { | ||
"psr-4": { | ||
"SyberIsle\\Laravel\\Cast\\Archive\\": "src" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"SyberIsle\\Laravel\\Cast\\Archive\\Test\\": "tests" | ||
} | ||
}, | ||
"config": { | ||
"sort-packages": true | ||
}, | ||
"scripts": { | ||
"sniff": "@php vendor/bin/phpcs", | ||
"stan": "vendor/bin/phpstan analyse --level 6 src", | ||
"test": "vendor/bin/testbench package:test" | ||
} | ||
} |
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,15 @@ | ||
<?xml version="1.0"?> | ||
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer" xsi:noNamespaceSchemaLocation="phpcs.xsd"> | ||
<description>Coding standard for this project</description> | ||
|
||
<config name="installed_paths" value="vendor/syberisle/coding-standards" /> | ||
|
||
<file>src</file> | ||
<file>tests</file> | ||
|
||
<rule ref="SyberIsle" /> | ||
|
||
<arg name="colors" /> | ||
<arg value="p" /> | ||
<arg name="extensions" value="php"/> | ||
</ruleset> |
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,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
stopOnFailure="true" | ||
cacheResult="false" | ||
> | ||
<testsuites> | ||
<testsuite name="Test Suite"> | ||
<directory suffix="Test.php">./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<coverage processUncoveredFiles="true"> | ||
<include> | ||
<directory suffix=".php">./app</directory> | ||
<directory suffix=".php">./src</directory> | ||
</include> | ||
</coverage> | ||
</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,41 @@ | ||
<?php | ||
|
||
namespace SyberIsle\Laravel\Cast\Archive; | ||
|
||
use Illuminate\Contracts\Database\Eloquent\CastsAttributes; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
/** | ||
* Uses the bzip functions to compress & decompress the data | ||
* | ||
* @implements CastsAttributes<mixed, mixed> | ||
*/ | ||
class BzArchive | ||
implements CastsAttributes | ||
{ | ||
/** | ||
* @param Model $model | ||
* @param string $key | ||
* @param mixed $value | ||
* @param mixed[] $attributes | ||
* | ||
* @return false|string|null | ||
*/ | ||
public function get($model, string $key, $value, array $attributes): mixed | ||
{ | ||
return bzdecompress($value); | ||
} | ||
|
||
/** | ||
* @param Model $model | ||
* @param string $key | ||
* @param mixed $value | ||
* @param mixed[] $attributes | ||
* | ||
* @return false|string|null | ||
*/ | ||
public function set($model, string $key, $value, array $attributes) | ||
{ | ||
return bzcompress($value); | ||
} | ||
} |
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,41 @@ | ||
<?php | ||
|
||
namespace SyberIsle\Laravel\Cast\Archive; | ||
|
||
use Illuminate\Contracts\Database\Eloquent\CastsAttributes; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
/** | ||
* Uses the gzip deflate functions to compress & decompress the data | ||
* | ||
* @implements CastsAttributes<mixed, mixed> | ||
*/ | ||
class GzArchive | ||
implements CastsAttributes | ||
{ | ||
/** | ||
* @param Model $model | ||
* @param string $key | ||
* @param mixed $value | ||
* @param mixed[] $attributes | ||
* | ||
* @return false|string|null | ||
*/ | ||
public function get($model, string $key, $value, array $attributes): mixed | ||
{ | ||
return gzinflate($value); | ||
} | ||
|
||
/** | ||
* @param Model $model | ||
* @param string $key | ||
* @param mixed $value | ||
* @param mixed[] $attributes | ||
* | ||
* @return false|string|null | ||
*/ | ||
public function set($model, string $key, $value, array $attributes): mixed | ||
{ | ||
return gzdeflate($value); | ||
} | ||
} |
Oops, something went wrong.