Skip to content

Commit

Permalink
Snake case configuration values
Browse files Browse the repository at this point in the history
  • Loading branch information
endroid committed Aug 3, 2024
1 parent 3ac0a87 commit 74cf5db
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 33 deletions.
4 changes: 3 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/.github/workflows/ export-ignore
/.github/ export-ignore
/tests/ export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
12 changes: 6 additions & 6 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
php-versions: ['8.1', '8.2', '8.3']
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
Expand All @@ -26,7 +26,7 @@ jobs:
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache composer dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
Expand Down Expand Up @@ -58,13 +58,13 @@ jobs:
- name: Archive logs
if: ${{ failure() }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: logs
name: logs-php-${{ matrix.php-versions }}
path: vendor/endroid/quality/application/var/log

- name: Archive code coverage results
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage
name: coverage-php-${{ matrix.php-versions }}
path: tests/coverage
6 changes: 3 additions & 3 deletions .install/symfony/config/packages/endroid_qr_code.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ endroid_qr_code:
size: 300
margin: 10
encoding: 'UTF-8'
errorCorrectionLevel: 'low'
roundBlockSizeMode: 'margin'
validateResult: false
error_correction_level: 'low'
round_block_size_mode: 'margin'
validate_result: false
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,23 @@ endroid_qr_code:
writer: Endroid\QrCode\Writer\PngWriter
data: 'This is customized QR code'
# Label is not implemented for SvgWriter
labelText: 'This is the label'
labelFontPath: '%kernel.project_dir%/vendor/endroid/qr-code/assets/noto_sans.otf'
labelFontSize: 20
labelAlignment: 'center'
label_text: 'This is the label'
label_font_path: '%kernel.project_dir%/vendor/endroid/qr-code/assets/noto_sans.otf'
label_font_size: 20
label_alignment: 'center'
custom:
writer: Endroid\QrCode\Writer\SvgWriter
writerOptions:
writer_options:
exclude_xml_declaration: true # default: false
data: 'This is customized QR code'
size: 300
encoding: 'UTF-8'
errorCorrectionLevel: 'low' # 'low', 'medium', 'quartile', or 'high'
roundBlockSizeMode: 'margin'
logoPath: '%kernel.project_dir%/vendor/endroid/qr-code/tests/assets/symfony.png'
logoResizeToWidth: 150
logoPunchoutBackground: true
validateResult: false
error_correction_level: 'low' # 'low', 'medium', 'quartile', or 'high'
round_block_size_mode: 'margin'
logo_path: '%kernel.project_dir%/vendor/endroid/qr-code/tests/assets/symfony.png'
logo_resize_to_width: 150
logo_punchout_background: true
validate_result: false
```
## Using builders
Expand Down
6 changes: 6 additions & 0 deletions src/DependencyInjection/EndroidQrCodeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ private function createBuilderDefinition(string $builderName, array $builderConf

$options = [];
foreach ($builderConfig as $name => $value) {
$name = $this->toCamelCase($name);
switch ($name) {
case 'writer':
$options[$name] = new Reference($value);
Expand Down Expand Up @@ -105,4 +106,9 @@ private function createBuilderDefinition(string $builderName, array $builderConf

return $builderDefinition;
}

private function toCamelCase(string $anyCase): string
{
return lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $anyCase))));
}
}
24 changes: 12 additions & 12 deletions tests/application/config/packages/endroid_qr_code.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@ endroid_qr_code:
default:
writer: Endroid\QrCode\Writer\PngWriter
data: 'This is customized QR code'
labelText: 'This is the label'
label_text: 'This is the label'
custom:
writer: Endroid\QrCode\Writer\SvgWriter
writerOptions: []
writer_options: []
data: 'This is customized QR code'
size: 300
encoding: 'UTF-8'
errorCorrectionLevel: 'high'
roundBlockSizeMode: 'margin'
logoPath: '%kernel.project_dir%/assets/symfony.png'
logoResizeToWidth: 150
labelText: 'This is the label'
labelFontPath: '%kernel.project_dir%/assets/open_sans.ttf'
labelFontSize: 20
labelAlignment: 'center'
validateResult: false
error_correction_level: 'high'
round_block_size_mode: 'margin'
logo_path: '%kernel.project_dir%/assets/symfony.png'
logo_resize_to_width: 150
label_text: 'This is the label'
label_font_path: '%kernel.project_dir%/assets/open_sans.ttf'
label_font_size: 20
label_alignment: 'center'
validate_result: false
debug:
writer: Endroid\QrCode\Writer\DebugWriter
data: 'This is the QR code we debug'
encoding: 'ISO-8859-1'
labelText: 'This is the label'
label_text: 'This is the label'

0 comments on commit 74cf5db

Please sign in to comment.