Skip to content

Commit ea06a04

Browse files
committed
Initial commit
1 parent e047f4b commit ea06a04

File tree

14 files changed

+5616
-0
lines changed

14 files changed

+5616
-0
lines changed

.github/copilot-instructions.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!-- Use this file to provide workspace-specific custom instructions to Copilot. For more details, visit https://code.visualstudio.com/docs/copilot/copilot-customization#_use-a-githubcopilotinstructionsmd-file -->
2+
3+
All code comments should be written in English.
4+
5+
All messages, including error messages, should be written in English.
6+
7+
All code should be written in PHP 8.4 or later.
8+
9+
All code should follow the PSR-12 coding standard.
10+
11+
When writing code, always include a docblock for functions and classes, describing their purpose, parameters, and return types.
12+
13+
When writing tests, use PHPUnit and follow the PSR-12 coding standard.
14+
15+
When writing documentation, use reStructuredText (reST) format.
16+
17+
When writing commit messages, use the imperative mood and keep them concise.
18+
19+
When writing code comments, use complete sentences and proper grammar.
20+
21+
When writing code, always use meaningful variable names that describe their purpose.
22+
23+
When writing code, avoid using magic numbers or strings; instead, define constants for them.
24+
25+
When writing code, always handle exceptions properly and provide meaningful error messages.
26+
27+
When writing code, always include type hints for function parameters and return types.
28+
29+
We are using the i18n library for internationalization, so always use the _() functions for strings that need to be translated.
30+
31+
When writing code, always ensure that it is secure and does not expose any sensitive information.
32+
33+
When writing code, always consider performance and optimize where necessary.
34+
35+
When writing code, always ensure that it is compatible with the latest version of PHP and the libraries we are using.
36+
37+
When writing code, always ensure that it is well-tested and includes unit tests where applicable.
38+
39+
When writing code, always ensure that it is maintainable and follows best practices.
40+
41+
When create new class or update existing class, always create or update its phpunit test files.
42+
43+

.github/dependabot.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "composer"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
open-pull-requests-limit: 10
8+
versioning-strategy: increase
9+
commit-message:
10+
prefix: "composer"
11+
- package-ecosystem: "github-actions"
12+
directory: "/"
13+
schedule:
14+
interval: "weekly"

.github/workflows/php.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: PHP Composer
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v5
19+
20+
- name: Validate composer.json and composer.lock
21+
run: composer validate --strict
22+
23+
- name: Cache Composer packages
24+
id: composer-cache
25+
uses: actions/cache@v4
26+
with:
27+
path: vendor
28+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
29+
restore-keys: |
30+
${{ runner.os }}-php-
31+
32+
- name: Install dependencies
33+
run: composer install --prefer-dist --no-progress
34+
35+
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
36+
# Docs: https://getcomposer.org/doc/articles/scripts.md
37+
38+
# - name: Run test suite
39+
# run: composer run-script test

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ composer.phar
44
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
55
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
66
# composer.lock
7+
/nbproject/private/
8+
/.build/
9+
/nbproject/
10+
/tests/*.abo*
11+

.php-cs-fixer.dist.php

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of the PohodaRaiffeisenbank package
7+
*
8+
* https://github.com/Spoje-NET/php-abo-parser
9+
*
10+
* (c) Spoje.Net IT s.r.o. <https://spojenet.cz>
11+
*
12+
* For the full copyright and license information, please view the LICENSE
13+
* file that was distributed with this source code.
14+
*/
15+
16+
use Ergebnis\PhpCsFixer\Config\Factory;
17+
use Ergebnis\PhpCsFixer\Config\Rules;
18+
use Ergebnis\PhpCsFixer\Config\RuleSet\Php81;
19+
20+
$header = <<<'HEADER'
21+
This file is part of the PohodaRaiffeisenbank package
22+
23+
https://github.com/Spoje-NET/php-abo-parser
24+
25+
(c) Spoje.Net IT s.r.o. <https://spojenet.cz>
26+
27+
For the full copyright and license information, please view the LICENSE
28+
file that was distributed with this source code.
29+
HEADER;
30+
31+
$ruleSet = Php81::create()->withHeader($header)->withRules(Rules::fromArray([
32+
'blank_line_before_statement' => [
33+
'statements' => [
34+
'break',
35+
'continue',
36+
'declare',
37+
'default',
38+
'do',
39+
'exit',
40+
'for',
41+
'foreach',
42+
'goto',
43+
'if',
44+
'include',
45+
'include_once',
46+
'require',
47+
'require_once',
48+
'return',
49+
'switch',
50+
'throw',
51+
'try',
52+
'while',
53+
],
54+
],
55+
'concat_space' => [
56+
'spacing' => 'none',
57+
],
58+
'date_time_immutable' => false,
59+
'error_suppression' => false,
60+
'final_class' => false,
61+
'mb_str_functions' => false,
62+
'native_function_invocation' => [
63+
'exclude' => [
64+
'sprintf',
65+
],
66+
'include' => [
67+
'@compiler_optimized',
68+
],
69+
'scope' => 'all',
70+
'strict' => false,
71+
],
72+
'php_unit_internal_class' => false,
73+
'php_unit_test_annotation' => [
74+
'style' => 'prefix',
75+
],
76+
'php_unit_test_class_requires_covers' => false,
77+
'return_to_yield_from' => false,
78+
'phpdoc_array_type' => false,
79+
'phpdoc_list_type' => false,
80+
'attribute_empty_parentheses' => false,
81+
'final_public_method_for_abstract_class' => false,
82+
'class_attributes_separation' => [
83+
'elements' => [
84+
'const' => 'only_if_meta',
85+
'property' => 'only_if_meta',
86+
'trait_import' => 'none',
87+
'case' => 'none',
88+
],
89+
],
90+
'yoda_style' => false,
91+
'php_unit_test_case_static_method_calls' => false,
92+
]));
93+
94+
$config = Factory::fromRuleSet($ruleSet)->setUnsupportedPhpVersionAllowed(true);
95+
96+
$config->getFinder()
97+
->append([
98+
__DIR__.'/.php-cs-fixer.dist.php',
99+
])
100+
->in('src')
101+
->in('tests');
102+
103+
$config->setCacheFile(__DIR__.'/.build/php-cs-fixer/.php-cs-fixer.cache');
104+
105+
return $config;

Example/abo2json.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
/**
5+
* This file is part of the CSas Statement Tools package
6+
*
7+
* https://github.com/VitexSoftware/file2sharepoint
8+
*
9+
* (c) Vítězslav Dvořák <info@vitexsoftware.cz>
10+
*
11+
* For the full copyright and license information, please view the LICENSE
12+
* file that was distributed with this source code.
13+
*/
14+
15+
require_once '../vendor/autoload.php';
16+
17+
\define('APP_NAME', 'abo2json');
18+
19+
if ($argc === 1) {
20+
echo $argv[0]." <source/files/path/*.*> <Sharepoint/dest/folder/path/> [/path/to/config/.env] \n";
21+
}
22+

Makefile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# vim: set tabstop=8 softtabstop=8 noexpandtab:
2+
.PHONY: help
3+
help: ## Displays this list of targets with descriptions
4+
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}'
5+
6+
.PHONY: token
7+
token: ## Refresh token
8+
csas-access-token -t`csas-access-token -l | head -n 1 | awk '{print $$2}'` -o.env
9+
10+
.PHONY: static-code-analysis
11+
static-code-analysis: vendor ## Runs a static code analysis with phpstan/phpstan
12+
vendor/bin/phpstan analyse --configuration=phpstan-default.neon.dist --memory-limit=-1
13+
14+
.PHONY: static-code-analysis-baseline
15+
static-code-analysis-baseline: check-symfony vendor ## Generates a baseline for static code analysis with phpstan/phpstan
16+
vendor/bin/phpstan analyze --configuration=phpstan-default.neon.dist --generate-baseline=phpstan-default-baseline.neon --memory-limit=-1
17+
18+
.PHONY: tests
19+
tests: vendor
20+
vendor/bin/phpunit tests
21+
22+
.PHONY: vendor
23+
vendor: composer.json composer.lock ## Installs composer dependencies
24+
composer install
25+
26+
.PHONY: cs
27+
cs: ## Update Coding Standards
28+
vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --diff --verbose --allow-risky=yes
29+

composer.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "spojenet/abo-parser",
3+
"description": "Czechoslovak ABO format parsing library",
4+
"type": "library",
5+
"license": "MIT",
6+
"autoload": {
7+
"psr-4": {
8+
"SpojeNet\\AboParser\\": "src/AboParser"
9+
}
10+
},
11+
"authors": [
12+
{
13+
"name": "CyberVitexus",
14+
"email": "info@vitexsoftware.cz"
15+
}
16+
],
17+
"minimum-stability": "dev",
18+
"require-dev": {
19+
"phpunit/phpunit": "*",
20+
"phpstan/phpstan": "*",
21+
"friendsofphp/php-cs-fixer": "^3.75",
22+
"ergebnis/composer-normalize": "^2.47",
23+
"ergebnis/php-cs-fixer-config": "^6.46"
24+
},
25+
"config": {
26+
"allow-plugins": {
27+
"ergebnis/composer-normalize": true
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)