Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes video title validator #48

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions src/Item/Video/VideoItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,18 @@ protected function setTitle($title)
*/
protected function setContentLoc($loc)
{
self::writeFullTag(
$loc,
'content_loc',
true,
'video:content_loc',
$this->validator,
'validateContentLoc',
$this->exception,
'Provided content URL is not a valid.'
);
if ($loc) {
self::writeFullTag(
$loc,
'content_loc',
true,
'video:content_loc',
$this->validator,
'validateContentLoc',
$this->exception,
'Provided content URL is not a valid.'
);
}

return $this;
}
Expand All @@ -131,12 +133,14 @@ protected function setContentLoc($loc)
*/
protected function setPlayerLoc($loc, $playerEmbedded, $playerAutoPlay)
{
self::$xml['player_loc'] = VideoItemPlayerTags::setPlayerLoc(
$this->validator,
$loc,
$playerEmbedded,
$playerAutoPlay
);
if ($loc) {
self::$xml['player_loc'] = VideoItemPlayerTags::setPlayerLoc(
$this->validator,
$loc,
$playerEmbedded,
$playerAutoPlay
);
}

return $this;
}
Expand Down
9 changes: 7 additions & 2 deletions src/Item/Video/VideoItemValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,16 @@ public function validateThumbnailLoc($loc)
/**
* @param $title
*
* @return bool
* @return string|false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the return annotation should be type hint.

That is, it should be string|bool.

*/
public function validateTitle($title)
{
return self::validateString($title) && \strlen($title) < 97;
$length = \mb_strlen($title, 'UTF-8');
if ($length > 0 && $length < 97) {
return self::validateString($title);
}

return false;
}

/**
Expand Down