Skip to content

Commit

Permalink
Not all files have a viewBox
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-42 committed Jul 4, 2020
1 parent 59527c8 commit 093e73f
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 31 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Expand Up @@ -10,7 +10,6 @@
/.gitignore export-ignore
/.php_cs export-ignore
/.scrutinizer.yml export-ignore
/.travis.yml export-ignore
/README.md export-ignore
/phpcs.xml.dist export-ignore
/phpunit.xml.dist export-ignore
27 changes: 0 additions & 27 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -60,8 +60,8 @@
"scripts-descriptions": {
"php-cs-fixer": "Cleans to code with PHP Coding Standards Fixer.",
"phpcs": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
"phpmd": "Runs the PHP Mess Detector.",
"phpunit": "Runs the PHPUnit programmer-oriented testing framework."
"phpmd": "PHP Mess Detector.",
"phpunit": "PHPUnit - programmer-oriented testing framework."
},
"extra": {
"branch-alias": {
Expand Down
3 changes: 2 additions & 1 deletion src/helpers/Svg.php
Expand Up @@ -184,7 +184,8 @@ private function getSize(): array
$svgWidth = $this->getPixelValue($this->svgElement->getAttribute('width'));
$svgHeight = $this->getPixelValue($this->svgElement->getAttribute('height'));

[$xStart, $yStart, $xEnd, $yEnd] = explode(' ', $this->svgElement->getAttribute('viewBox') ?: '');
$viewBox = $this->svgElement->getAttribute('viewBox') ?: "0 0 {$svgWidth} {$svgHeight}";
[$xStart, $yStart, $xEnd, $yEnd] = explode(' ', $viewBox);
$viewBoxWidth = isset($xStart, $xEnd) ? $xEnd - $xStart : 0;
$viewBoxHeight = isset($yStart, $yEnd) ? $yEnd - $yStart : 0;

Expand Down
1 change: 1 addition & 0 deletions tests/IconClassTest.php
Expand Up @@ -13,6 +13,7 @@ public function testBasic(): void
$this->assertStringContainsString('viewBox="0 0 192 512" aria-hidden="true" role="img" class="svg-inline--fa svg-inline--fa-w-6"', $icon->show('ellipsis-v'));
$this->assertStringContainsString('viewBox="0 0 496 512" aria-hidden="true" role="img" class="svg-inline--fa svg-inline--fa-w-16"', $icon->show('github', ['style' => 'brands']));
$this->assertStringContainsString('viewBox="0 0 512 512" aria-hidden="true" role="img" class="svg-inline--fa svg-inline--fa-w-16"', $icon->show('nonexistent'));
$this->assertStringContainsString('width="390" height="250"', $icon->show('@vendor/pdepend/pdepend/src/main/php/PDepend/Report/Jdepend/chart.svg'));
}

public function testClass(): void
Expand Down
1 change: 1 addition & 0 deletions tests/tests.php
Expand Up @@ -21,6 +21,7 @@ protected function mockWebApplication($config = [], $appClass = '\yii\web\Applic
'vendorPath' => dirname(__DIR__).'/vendor',
'aliases' => [
'@bower' => '@vendor/bower-asset',
'@tests' => '@app/../tests',
],
'components' => [
'request' => [
Expand Down

0 comments on commit 093e73f

Please sign in to comment.