diff --git a/src/Support/Iconamic.php b/src/Support/Iconamic.php index ea1db76..41da2d0 100644 --- a/src/Support/Iconamic.php +++ b/src/Support/Iconamic.php @@ -2,7 +2,6 @@ namespace MityDigital\Iconamic\Support; -use Illuminate\Support\Str; use MityDigital\Iconamic\Exceptions\IconamicException; class Iconamic @@ -32,32 +31,26 @@ public function cleanSvg(string $svg, int $index, array $attributes = []): strin $dom->loadXML($svg, LIBXML_NOERROR); // if we have classReplace, do this first because it may be appended to by "class" - if (array_key_exists('classReplace', $attributes)) - { + if (array_key_exists('classReplace', $attributes)) { // set the class from classReplace $dom->documentElement->setAttribute('class', $attributes['classReplace']); unset($attributes['classReplace']); } - foreach($attributes as $attribute => $value) - { - if ($attribute === 'class') - { - if ($dom->documentElement->hasAttribute('class')) - { + foreach ($attributes as $attribute => $value) { + if ($attribute === 'class') { + if ($dom->documentElement->hasAttribute('class')) { // append to the class $existing = $dom->documentElement->getAttribute('class'); $dom->documentElement->setAttribute($attribute, $existing.' '.$value); - } - else { + } else { // add the class $dom->documentElement->setAttribute($attribute, $value); } - } - else { + } else { // overwrite attribute - simply add it - $dom->documentElement->setAttribute(Str::kebab($attribute), $value); + $dom->documentElement->setAttribute($attribute, $value); } } diff --git a/tests/Fieldtypes/IconamicFieldtypeTest.php b/tests/Fieldtypes/IconamicFieldtypeTest.php index d0242d1..51b1055 100644 --- a/tests/Fieldtypes/IconamicFieldtypeTest.php +++ b/tests/Fieldtypes/IconamicFieldtypeTest.php @@ -53,7 +53,7 @@ public function preload_gets_list_of_icons_using_defaults() $icons = $this->fieldtype->preload(); $this->assertArrayHasKey('icons', $icons); - $this->assertCount(4, $icons['icons']); + $this->assertCount(5, $icons['icons']); } /** @test */ @@ -72,6 +72,6 @@ public function preload_gets_list_of_icons_using_field_overrides() $icons = $this->fieldtype->preload(); $this->assertArrayHasKey('icons', $icons); - $this->assertCount(2, $icons['icons']); + $this->assertCount(3, $icons['icons']); } } diff --git a/tests/Support/IconamicSupportTest.php b/tests/Support/IconamicSupportTest.php index acf4c7d..e14a17f 100644 --- a/tests/Support/IconamicSupportTest.php +++ b/tests/Support/IconamicSupportTest.php @@ -122,20 +122,6 @@ public function clean_svg_can_apply_additional_attributes() 'monkey' => 'tail' ])); - // ensure attribute is converted to kebab case - $this->assertEquals( - '', - Iconamic::cleanSvg('', 2, [ - 'strokeWidth' => '2' - ])); - - // ensure kebab case remains as is - $this->assertEquals( - '', - Iconamic::cleanSvg('', 2, [ - 'stroke-width' => '2' - ])); - // id is updated accordingly by the cleaner, and left as is $this->assertEquals( '',