Skip to content

Commit 2623615

Browse files
committed
Bugfix for custom elements.
1 parent 8182ce0 commit 2623615

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/Feed.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,18 @@ public function getEntries(): array
138138

139139
/**
140140
* @param string $ns
141-
* @param string $url
141+
* @param string $uri
142142
* @param string $name
143143
* @param mixed $value
144144
* @param null|string[] $attributes
145145
*/
146-
public function addCustomElement(string $ns, string $url, string $name, $value, ?array $attributes = null): void
146+
public function addCustomElement(string $ns, string $uri, string $name, $value, ?array $attributes = null): void
147147
{
148-
self::assertURL($url);
148+
self::assertURL($uri);
149149

150150
$this->customElements[] = [
151151
'ns' => $ns,
152-
'url' => $url,
152+
'uri' => $uri,
153153
'name' => $name,
154154
'value' => $value,
155155
'attributes' => $attributes ?? [],
@@ -186,7 +186,7 @@ public function addChildrenTo(SimpleXMLElement $parent): void
186186
}
187187

188188
foreach ($this->customElements as $customElement) {
189-
$element = $parent->addChild($customElement['name'], $customElement['value'], $customElement['ns']);
189+
$element = $parent->addChild($customElement['name'], $customElement['value'], $customElement['uri']);
190190
foreach ($customElement['attributes'] as $name => $value) {
191191
$element->addAttribute($name, $value);
192192
}
@@ -207,7 +207,7 @@ public function getSimpleXML(): SimpleXMLElement
207207
$attributes['xml:lang'] = $this->language;
208208
}
209209
foreach ($this->customElements as $customElement) {
210-
$attributes['xmlns:'.$customElement['ns']] = $customElement['url'];
210+
$attributes['xmlns:'.$customElement['ns']] = $customElement['uri'];
211211
}
212212

213213
$attributesString = '';

tests/FeedTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function testFeedCreation1(): void
4040
$feed->addContributor('contributor', '[email protected]', 'http://test.com/contributor');
4141
$feed->setUpdatedDateTime(new DateTime('2019-05-04T20:00:40Z'));
4242
$feed->addCustomElement('sy', 'http://purl.org/rss/1.0/modules/syndication', 'updatePeriod', 'hourly');
43-
$feed->addCustomElement('sy', 'http://purl.org/rss/1.0/modules/syndication', 'sy:updateFrequency', 10);
43+
$feed->addCustomElement('sy', 'http://purl.org/rss/1.0/modules/syndication', 'updateFrequency', 10);
4444

4545
$entry = new Entry();
4646
$entry->setTitle('entry title', 'text');

tests/feed_1.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
<logo>http://test.com/logo</logo>
2626
<icon>http://test.com/icon</icon>
2727
<generator version="version" uri="http://test.com/generator">generator</generator>
28-
<updatePeriod xmlns="sy">hourly</updatePeriod>
29-
<sy:updateFrequency xmlns:sy="sy">10</sy:updateFrequency>
28+
<sy:updatePeriod>hourly</sy:updatePeriod>
29+
<sy:updateFrequency>10</sy:updateFrequency>
3030
<entry>
3131
<id>tag:entry-test</id>
3232
<title type="text">entry title</title>

0 commit comments

Comments
 (0)