Skip to content

Commit 0c2c924

Browse files
authored
Cast the length to comply with ints provided by JSON Feed alexdebril#374 (alexdebril#380)
1 parent 4fc5533 commit 0c2c924

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/FeedIo/Feed/Item/Media.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ public function getLength(): ?string
8888
}
8989

9090
/**
91-
* @param string|null $length
91+
* @param mixed $length
9292
* @return MediaInterface
9393
*/
94-
public function setLength(?string $length): MediaInterface
94+
public function setLength($length) : MediaInterface
9595
{
96-
$this->length = $length;
96+
$this->length = (string) intval($length);
9797

9898
return $this;
9999
}

src/FeedIo/Feed/Item/MediaInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ public function setUrl(?string $url): MediaInterface;
6161
public function getLength(): ?string;
6262

6363
/**
64-
* @param string $length
64+
* @param mixed $length
6565
* @return MediaInterface
6666
*/
67-
public function setLength(?string $length): MediaInterface;
67+
public function setLength($length) : MediaInterface;
6868

6969
/**
7070
* @return string

tests/samples/feed.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"attachments": [
2121
{
2222
"url": "http://localhost/some-resource.jpg",
23-
"mime_type": "image/jpg"
23+
"mime_type": "image/jpg",
24+
"size_in_bytes": 12345
2425
}
2526
]
2627
},

0 commit comments

Comments
 (0)