Skip to content

Commit f956f32

Browse files
authored
Merge pull request #31 from Pixelrobin/default-attributes-changes
Store attributes like icons
2 parents 6e9cbc8 + e73c21c commit f956f32

File tree

4 files changed

+12
-17
lines changed

4 files changed

+12
-17
lines changed

bin/build.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,11 @@ function writeAttributes(array $attributes): void
4646
$export = var_export($attributes, true);
4747

4848
file_put_contents(
49-
implode(DIRECTORY_SEPARATOR, [$rootDir, 'src', 'defaultAttributes.php']),
49+
implode(DIRECTORY_SEPARATOR, [$rootDir, 'resources', 'attributes.php']),
5050
<<<EOT
5151
<?php
5252
53-
/* !!! THIS FILE IS AUTO-GENERATED !!! */
54-
55-
namespace Feather;
56-
57-
const DEFAULT_ATTRIBUTES = $export;
53+
return $export;
5854
5955
EOT
6056
);

src/defaultAttributes.php renamed to resources/attributes.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
<?php
22

3-
/* !!! THIS FILE IS AUTO-GENERATED !!! */
4-
5-
namespace Feather;
6-
7-
const DEFAULT_ATTRIBUTES = array (
3+
return array (
84
'xmlns' => 'http://www.w3.org/2000/svg',
95
'width' => '24',
106
'height' => '24',

src/Icons.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@
44

55
use Feather\Exception\IconNotFoundException;
66

7-
require __DIR__ . '/defaultAttributes.php';
8-
97
class Icons
108
{
11-
private $attributes = DEFAULT_ATTRIBUTES;
9+
private $attributes;
1210

1311
private $icons;
1412

1513
public function __construct()
1614
{
17-
$this->icons = require implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), '..', 'resources', 'icons.php']);
15+
$this->attributes = require implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), '..', 'resources', 'attributes.php']);
16+
$this->icons = require implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), '..', 'resources', 'icons.php']);
1817
}
1918

2019
public function get(string $name, array $attributes = []): string

tests/FeatherTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ protected function setUp(): void
3939

4040
public function testIconsHasDefaultAttributes(): void
4141
{
42-
$this->assertEquals(Feather\DEFAULT_ATTRIBUTES, $this->icons->getAttributes());
42+
$attributes = require implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), '..', 'resources', 'attributes.php']);
43+
44+
$this->assertEquals($attributes, $this->icons->getAttributes());
4345
}
4446

4547
public function testIconDefaultXML(): void
@@ -68,6 +70,8 @@ public function testIconXMLWithAttributes(): void
6870

6971
public function testIconXMLWithAttributesFromClass(): void
7072
{
73+
$attributes = require implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), '..', 'resources', 'attributes.php']);
74+
7175
$test_data = $this->AttributeTestData;
7276

7377
$this->icons->setattributes($test_data['attributes']);
@@ -79,7 +83,7 @@ public function testIconXMLWithAttributesFromClass(): void
7983
'XML custom attribute on class fail'
8084
);
8185

82-
$this->icons->setAttributes(Feather\DEFAULT_ATTRIBUTES);
86+
$this->icons->setAttributes($attributes);
8387
}
8488

8589
public function testIconNotFound(): void

0 commit comments

Comments
 (0)