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

fix descripyion and price #6

Open
wants to merge 1 commit 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
2 changes: 1 addition & 1 deletion src/ymlDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ protected function newOffer( $id, $price, $currency, $category, $type, $from )
if( (!is_int($category)) || ($category<1) || ($category>=pow(10,19)) )
$this->exc("categoryId - целое число, не более 18 знаков");

if( !is_int($price) || $price<0 ) $this->exc("price должно быть целым и положительным");
if( !is_numeric($price) || $price<0 ) $this->exc("price должно быть положительным числом");
Copy link
Owner

Choose a reason for hiding this comment

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

В идеале в файлах документации (вроде docs/simple.md ) еще заменить int на numeric


if( !is_null($from)){
if( !is_bool($from) ) $this->exc('from должен быть boolean');
Expand Down
30 changes: 16 additions & 14 deletions src/ymlOffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,24 @@ public function dlvOption($cost,$days,$before = -1)
return $this;
}


public function description($txt,$tags = false)
/**
* @param string $txt
* @param bool $tags
* @return self
*/
public function description($txt, $tags = false)
{
$this->check( mb_strlen($txt,$this->enc)>3000 , "description должен быть короче 3000 символов" );

if( $tags ){
$cdata = new \DOMCdataSection($txt);
$desc = new \DomElement( 'description');
$this->appendChild($desc);
$desc->appendChild($cdata);
return $this;
}else{
return $this->add('description', $txt);
}


$desc = new \DomElement( 'description');
if ($tags) {
$cdata = new \DOMCdataSection($txt);
$this->appendChild($desc);
$desc->appendChild($cdata);
} else {
$desc->textContent = $txt;
$this->appendChild($desc);
}
return $this;
Comment on lines +128 to +137
Copy link
Owner

Choose a reason for hiding this comment

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

Это поправили в предыдущем PR, который уже влит. И там как-то компактнее, тут бросается в глаза два раза $this->appendChild($desc);

}


Expand Down