Skip to content

Commit 903b2e9

Browse files
Merge pull request #78 from TheDragonCode/1.x
Fixed error in the absence of a root element by default
2 parents 2c500cb + 488d790 commit 903b2e9

12 files changed

+96
-47
lines changed
Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2+
<array_directive>
3+
24
<user>
3-
<name>Ilene Renner</name>
4-
<avatar>https://via.placeholder.com/640x480.png/0099bb?text=consequatur</avatar>
5-
<avatar>https://via.placeholder.com/640x480.png/00ee33?text=ut</avatar>
6-
<images name="consequatur ipsum fuga">https://via.placeholder.com/640x480.png/008866?text=magnam</images>
7-
<images name="a consequatur est">https://via.placeholder.com/640x480.png/0099aa?text=optio</images>
5+
<name>Mr. Nathanael Davis</name>
6+
<avatar>https://via.placeholder.com/640x480.png/0055ff?text=in</avatar>
7+
<avatar>https://via.placeholder.com/640x480.png/001155?text=aperiam</avatar>
8+
<images name="amet sint dolor">https://via.placeholder.com/640x480.png/00cc66?text=excepturi</images>
9+
<images name="recusandae natus iure">https://via.placeholder.com/640x480.png/00cc99?text=velit</images>
810
</user>
911
<user>
10-
<name>Dr. Richard Rogahn Jr.</name>
11-
<avatar>https://via.placeholder.com/640x480.png/00aa55?text=et</avatar>
12-
<avatar>https://via.placeholder.com/640x480.png/00aa00?text=consequuntur</avatar>
13-
<images name="veniam consequatur quia">https://via.placeholder.com/640x480.png/00ff88?text=asperiores</images>
14-
<images name="asperiores quia voluptas">https://via.placeholder.com/640x480.png/0011aa?text=unde</images>
15-
</user>
12+
<name>Ms. Elouise Deckow</name>
13+
<avatar>https://via.placeholder.com/640x480.png/00bb66?text=voluptas</avatar>
14+
<avatar>https://via.placeholder.com/640x480.png/00cc99?text=pariatur</avatar>
15+
<images name="non autem reprehenderit">https://via.placeholder.com/640x480.png/009922?text=dolores</images>
16+
<images name="voluptas corrupti fugiat">https://via.placeholder.com/640x480.png/005533?text=quae</images>
17+
</user>
18+
19+
</array_directive>
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<company since="1983"/>
2+
<attributes_directive>
3+
4+
<company since="2013"/>
35
<url>https://example.com</url>
46

57
<user>
6-
<name>Grace Luettgen</name>
7-
<contact email="vdeckow@example.org" phone="555-000-1"/>
8+
<name>Loren Shields</name>
9+
<contact email="friesen.lewis@example.com" phone="555-000-1"/>
810
</user>
911
<user>
10-
<name>Stanton Dach DVM</name>
11-
<contact email="[email protected]" phone="555-000-2"/>
12-
</user>
12+
<name>Matilde Kohler DVM</name>
13+
<contact email="[email protected]" phone="555-000-2"/>
14+
</user>
15+
16+
</attributes_directive>
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2+
<cdata_directive>
3+
24
<user>
3-
<name><![CDATA[<h1>Prof. Clifford Kirlin IV</h1>]]></name>
4-
<email>skiles.foster@example.net</email>
5+
<name><![CDATA[<h1>Haley Purdy</h1>]]></name>
6+
<email>elmo56@example.com</email>
57
</user>
68
<user>
7-
<name><![CDATA[<h1>Nelle Frami</h1>]]></name>
8-
<email>[email protected]</email>
9-
</user>
9+
<name><![CDATA[<h1>Pearl Kozey</h1>]]></name>
10+
<email>[email protected]</email>
11+
</user>
12+
13+
</cdata_directive>
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2+
<mixed_directive>
3+
24
<user>
3-
<name>Palma Stokes</name>
5+
<name>Luis Beer DVM</name>
46
<some>
57
<first>Foo</first>
6-
<second>roscoe51@example.org</second>
8+
<second>kane.nader@example.com</second>
79
</some>
810
</user>
911
<user>
10-
<name>Geoffrey Treutel</name>
12+
<name>Claud Quigley IV</name>
1113
<some>
1214
<first>Foo</first>
13-
<second>heath.mosciski@example.org</second>
15+
<second>talon09@example.net</second>
1416
</some>
15-
</user>
17+
</user>
18+
19+
</mixed_directive>
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2+
<value_directive>
3+
24
<user>
3-
<name>Josiane Heller</name>
4-
<contact type="email">uriah41@example.com</contact>
5+
<name>Isac Hamill</name>
6+
<contact type="email">mathias01@example.org</contact>
57
</user>
68
<user>
7-
<name>Jermey Krajcik</name>
8-
<contact type="email">[email protected]</contact>
9-
</user>
9+
<name>Letha Lubowitz</name>
10+
<contact type="email">[email protected]</contact>
11+
</user>
12+
13+
</value_directive>
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<user created_at="2025-09-04 20:05:40">
2+
<attribute>
3+
4+
<user created_at="2025-09-04 20:11:33">
35
<id>1</id>
4-
<name>Jakayla Vandervort</name>
6+
<name>Dr. Timmothy Howell MD</name>
57
</user>
6-
<user created_at="2025-09-04 20:05:40">
8+
<user created_at="2025-09-04 20:11:33">
79
<id>2</id>
8-
<name>Prof. Garrick Gottlieb</name>
9-
</user>
10+
<name>Marcel Cummerata</name>
11+
</user>
12+
13+
</attribute>
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
2+
<header_footer>
3+
24
<user>
35
<id>1</id>
4-
<name>Summer Kuhlman</name>
6+
<name>Prof. Alberta Koch I</name>
57
</user>
68
<user>
79
<id>2</id>
8-
<name>Nicola Wiegand IV</name>
10+
<name>Judy Dietrich IV</name>
911
</user>
12+
13+
</header_footer>
14+
1015
<g:footer>This is a custom footer element</g:footer>
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2+
<info_method>
3+
24
<company>Laravel</company>
35
<url>https://example.com</url>
46

57
<user>
68
<id>1</id>
7-
<name>Francis Kassulke</name>
9+
<name>Miss Lina Nicolas</name>
810
</user>
911
<user>
1012
<id>2</id>
11-
<name>Katarina Morissette II</name>
12-
</user>
13+
<name>Dr. Jack Hagenes MD</name>
14+
</user>
15+
16+
</info_method>

docs/snippets/advanced-element-root.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
<user>
55
<id>1</id>
6-
<name>Prof. Ezra Hoeger</name>
6+
<name>Samantha Wilkinson</name>
77
</user>
88
<user>
99
<id>2</id>
10-
<name>Garth Heathcote</name>
10+
<name>Keyshawn Davis</name>
1111
</user>
1212

1313
</foo>

src/Feeds/Feed.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Illuminate\Support\Facades\Storage;
1616
use Illuminate\Support\Str;
1717

18+
use function class_basename;
19+
1820
abstract class Feed
1921
{
2022
protected FeedFormatEnum $format = FeedFormatEnum::Xml;
@@ -51,7 +53,13 @@ public function footer(): string
5153

5254
public function root(): ElementData
5355
{
54-
return new ElementData;
56+
return new ElementData(
57+
name: Str::of(static::class)
58+
->classBasename()
59+
->beforeLast(class_basename(self::class))
60+
->snake()
61+
->toString()
62+
);
5563
}
5664

5765
public function info(): FeedInfo

0 commit comments

Comments
 (0)