Skip to content

Commit

Permalink
fixed #2 issue
Browse files Browse the repository at this point in the history
  • Loading branch information
iGusev committed Jun 30, 2015
1 parent 56955fc commit e3f4abb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/BaseType.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static function validate($data)
public function map($data)
{
foreach (static::$map as $key => $item) {
if (isset($data[$key])) {
if (isset($data[$key]) && (!is_array($data[$key]) || (is_array($data[$key]) && !empty($data[$key])))) {
$method = 'set' . self::toCamelCase($key);
if ($item === true) {
$this->$method($data[$key]);
Expand All @@ -61,9 +61,9 @@ public function toJson($inner = false)
{
$output = array();

foreach (static::$map as $key => $item) {
foreach (static::$map as $key => $item) {
$property = lcfirst(self::toCamelCase($key));
if(!is_null($this->$property)) {
if (!is_null($this->$property)) {
$output[$key] = $item === true ? $this->$property : $this->$property->toJson(true);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Types/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Document extends BaseType implements TypeInterface
*
* @var array
*/
static protected $requiredParams = array('file_id', 'thumb');
static protected $requiredParams = array('file_id');

/**
* Unique identifier for this file
Expand Down
13 changes: 0 additions & 13 deletions tests/DocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,4 @@ public function testFromResponseException1()
)
));
}

/**
* @expectedException \TelegramBot\Api\InvalidArgumentException
*/
public function testFromResponseException2()
{
$item = Document::fromResponse(array(
'file_id' => 'testFileId1',
'file_name' => 'testFileName',
'mime_type' => 'audio/mp3',
'file_size' => 3
));
}
}

0 comments on commit e3f4abb

Please sign in to comment.