-
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 0ffefbe
Showing
20 changed files
with
1,094 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,68 @@ | ||
<?php | ||
|
||
use PhpCsFixer\Config; | ||
|
||
return (new Config()) | ||
->setUsingCache(false) | ||
->setRiskyAllowed(true) | ||
->setRules( | ||
[ | ||
'@PSR1' => true, | ||
'@PSR2' => true, | ||
'@Symfony' => true, | ||
'psr_autoloading' => true, | ||
// custom rules | ||
'align_multiline_comment' => ['comment_type' => 'phpdocs_only'], // psr-5 | ||
'phpdoc_to_comment' => false, | ||
'no_superfluous_phpdoc_tags' => false, | ||
'array_indentation' => true, | ||
'array_syntax' => ['syntax' => 'short'], | ||
'cast_spaces' => ['space' => 'none'], | ||
'concat_space' => ['spacing' => 'one'], | ||
'compact_nullable_type_declaration' => true, | ||
'declare_equal_normalize' => ['space' => 'single'], | ||
'general_phpdoc_annotation_remove' => [ | ||
'annotations' => [ | ||
'author', | ||
'package', | ||
], | ||
], | ||
'increment_style' => ['style' => 'post'], | ||
'list_syntax' => ['syntax' => 'short'], | ||
'echo_tag_syntax' => ['format' => 'long'], | ||
'phpdoc_add_missing_param_annotation' => ['only_untyped' => false], | ||
'phpdoc_align' => false, | ||
'phpdoc_no_empty_return' => false, | ||
'phpdoc_order' => true, // psr-5 | ||
'phpdoc_no_useless_inheritdoc' => false, | ||
'protected_to_private' => false, | ||
'yoda_style' => false, | ||
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'], | ||
'ordered_imports' => [ | ||
'sort_algorithm' => 'alpha', | ||
'imports_order' => ['class', 'const', 'function'], | ||
], | ||
'single_line_throw' => false, | ||
'declare_strict_types' => false, | ||
'blank_line_between_import_groups' => true, | ||
'fully_qualified_strict_types' => true, | ||
'no_null_property_initialization' => false, | ||
'operator_linebreak' => [ | ||
'only_booleans' => true, | ||
'position' => 'beginning', | ||
], | ||
'global_namespace_import' => [ | ||
'import_classes' => true, | ||
'import_constants' => null, | ||
'import_functions' => null | ||
] | ||
] | ||
) | ||
->setFinder( | ||
PhpCsFixer\Finder::create() | ||
->in(__DIR__ . '/src') | ||
->in(__DIR__ . '/tests') | ||
->name('*.php') | ||
->ignoreDotFiles(true) | ||
->ignoreVCS(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,22 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
end_of_line = lf | ||
|
||
[composer.json] | ||
indent_size = 4 | ||
|
||
[*.js] | ||
indent_size = 4 | ||
|
||
[*.neon] | ||
indent_size = 4 | ||
indent_style = tab | ||
|
||
[*.xml] | ||
indent_size = 4 | ||
|
||
[*.yml] | ||
indent_size = 4 |
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 @@ | ||
# Path-based git attributes | ||
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html | ||
|
||
public/* linguist-vendored | ||
docs/* linguist-documentation | ||
|
||
# Set the default behavior, in case people don't have core.autocrlf set. | ||
# Git will always convert line endings to LF on checkout. You should use | ||
# this for files that must keep LF endings, even on Windows. | ||
* text eol=lf | ||
|
||
# ------------------------------------------------------------------------------ | ||
# All the files and directories that can be excluded from dist, | ||
# we could have a more clean vendor/ | ||
# | ||
# So when someone will install that package through with --prefer-dist option, | ||
# all the files and directories listed in .gitattributes file will be excluded. | ||
# This could have a big impact on big deployments and/or testing. | ||
# ------------------------------------------------------------------------------ | ||
|
||
/.github export-ignore | ||
/tests export-ignore | ||
/build export-ignore | ||
/docs export-ignore | ||
/.cs.php export-ignore | ||
/.editorconfig export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.scrutinizer.* export-ignore | ||
/._config.yml export-ignore | ||
/phpcs.xml export-ignore | ||
/phpstan.neon export-ignore | ||
/phpunit.xml export-ignore | ||
|
||
# Define binary file attributes. | ||
# - Do not treat them as text. | ||
# - Include binary diff in patches instead of "binary files differ." | ||
*.pdf binary | ||
*.mo binary | ||
*.gif binary | ||
*.ico binary | ||
*.jpg binary | ||
*.jpeg binary | ||
*.png binary | ||
*.zip binary | ||
*.gif binary | ||
*.ico binary | ||
*.phar binary | ||
*.gz binary | ||
*.otf binary | ||
*.eot binary | ||
*.svg binary | ||
*.ttf binary | ||
*.woff binary | ||
*.woff2 binary |
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 @@ | ||
name: build | ||
|
||
on: [ push, pull_request ] | ||
|
||
jobs: | ||
run: | ||
runs-on: ${{ matrix.operating-system }} | ||
strategy: | ||
matrix: | ||
operating-system: [ ubuntu-latest ] | ||
php-versions: [ '8.1', '8.2' ] | ||
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }} | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v1 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-versions }} | ||
extensions: mbstring, intl, zip | ||
coverage: none | ||
|
||
- name: Check PHP Version | ||
run: php -v | ||
|
||
- name: Check Composer Version | ||
run: composer -V | ||
|
||
- name: Check PHP Extensions | ||
run: php -m | ||
|
||
- name: Validate composer.json and composer.lock | ||
run: composer validate | ||
|
||
- name: Install dependencies | ||
run: composer install --prefer-dist --no-progress --no-suggest | ||
|
||
- name: Run test suite | ||
run: composer test:all |
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 @@ | ||
.idea/ | ||
composer.lock | ||
nbproject/ | ||
vendor/ | ||
build/ | ||
.phpunit.cache/ | ||
.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,41 @@ | ||
filter: | ||
paths: [ "src/*" ] | ||
excluded_paths: [ "vendor/*", "tests/*" ] | ||
|
||
checks: | ||
php: | ||
code_rating: true | ||
duplication: true | ||
|
||
tools: | ||
external_code_coverage: false | ||
|
||
build: | ||
environment: | ||
php: | ||
version: 8.1.2 | ||
ini: | ||
xdebug.mode: coverage | ||
mysql: false | ||
node: false | ||
postgresql: false | ||
mongodb: false | ||
elasticsearch: false | ||
redis: false | ||
memcached: false | ||
neo4j: false | ||
rabbitmq: false | ||
nodes: | ||
analysis: | ||
tests: | ||
override: | ||
- php-scrutinizer-run | ||
dependencies: | ||
before: | ||
- composer self-update | ||
tests: | ||
before: | ||
- command: composer test:coverage | ||
coverage: | ||
file: 'build/logs/clover.xml' | ||
format: 'clover' |
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,22 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2023 odan | ||
|
||
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,55 @@ | ||
# odan/excel | ||
|
||
Extreme fast in-memory Excel (XLSX) file writer. | ||
|
||
## Requirements | ||
|
||
* PHP 8.1+ | ||
|
||
## Features | ||
|
||
- Extreme performance and minimal memory usage. | ||
- Dynamic sheet name. | ||
- Bold font for header column. | ||
|
||
## Installation | ||
|
||
```bash | ||
composer require odan/exel | ||
``` | ||
|
||
## Usage | ||
|
||
```php | ||
use Odan\Excel\ExcelWriter; | ||
use Odan\Excel\ZipFile; | ||
$file = new ZipFile(); | ||
$excel = new ExcelWriter($file); | ||
|
||
$excel->setSheetName('My Sheet'); | ||
|
||
$head = ['Date', 'Name', 'Amount']; | ||
$excel->writeHead($head); | ||
|
||
// Write data | ||
$rows = [ | ||
['2023-01-31', 'James', '220'], | ||
['2023-03-28', 'Mike', '153.5'], | ||
['2024-07-02', 'John', '34.12'], | ||
]; | ||
|
||
foreach ($rows as $row) { | ||
$excel->writeRow($row); | ||
} | ||
|
||
// Generate Excel file | ||
$excel->generate(); | ||
|
||
// Save as Excel file | ||
$data = stream_get_contents($file->getStream()); | ||
file_put_contents(__DIR__ . '/excel.xlsx', $data); | ||
``` | ||
|
||
## License | ||
|
||
The MIT License (MIT). Please see [License File](LICENSE) 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,56 @@ | ||
{ | ||
"name": "odan/excel", | ||
"description": "In-memory Excel file writer", | ||
"license": "MIT", | ||
"type": "library", | ||
"keywords": [ | ||
"Excel", | ||
"xlsx", | ||
"memory" | ||
], | ||
"homepage": "https://github.com/odan/excel", | ||
"require": { | ||
"php": "^8.1", | ||
"maennchen/zipstream-php": "^3.1" | ||
}, | ||
"require-dev": { | ||
"friendsofphp/php-cs-fixer": "^3", | ||
"phpstan/phpstan": "^1", | ||
"phpunit/phpunit": "^10", | ||
"squizlabs/php_codesniffer": "^3" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Odan\\Excel\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Odan\\Excel\\Test\\": "tests/" | ||
} | ||
}, | ||
"config": { | ||
"sort-packages": true | ||
}, | ||
"scripts": { | ||
"cs:check": [ | ||
"@putenv PHP_CS_FIXER_IGNORE_ENV=1", | ||
"php-cs-fixer fix --dry-run --format=txt --verbose --diff --config=.cs.php --ansi" | ||
], | ||
"cs:fix": [ | ||
"@putenv PHP_CS_FIXER_IGNORE_ENV=1", | ||
"php-cs-fixer fix --config=.cs.php --ansi --verbose" | ||
], | ||
"sniffer:check": "phpcs --standard=phpcs.xml", | ||
"sniffer:fix": "phpcbf --standard=phpcs.xml", | ||
"stan": "phpstan analyse -c phpstan.neon --no-progress --ansi", | ||
"test": "phpunit --configuration phpunit.xml --do-not-cache-result --colors=always", | ||
"test:all": [ | ||
"@cs:check", | ||
"@sniffer:check", | ||
"@stan", | ||
"@test" | ||
], | ||
"test:coverage": "php -d xdebug.mode=coverage -r \"require 'vendor/bin/phpunit';\" -- --configuration phpunit.xml --do-not-cache-result --colors=always --coverage-clover build/logs/clover.xml --coverage-html build/coverage" | ||
} | ||
} |
Oops, something went wrong.