Skip to content

Commit

Permalink
Merge pull request #126 from renderforest/null-issue
Browse files Browse the repository at this point in the history
null-issue
  • Loading branch information
narekhovhannisyan authored Feb 12, 2019
2 parents 634da99 + 2930bb0 commit 8150ca7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "renderforest/sdk-php",
"description": "Renderforest SDK for PHP",
"version": "0.3.11",
"version": "0.3.12",
"homepage": "https://github.com/renderforest/renderforest-sdk-php",
"authors": [
{
Expand Down
51 changes: 26 additions & 25 deletions src/ProjectData/ProjectData.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,19 +323,14 @@ public function constructScreen($screen)
$constructedScreen = [
'id' => isset($screen['id']) ? $screen['id'] : NULL,
'characterBasedDuration' => isset($screen['characterBasedDuration']) ? $screen['characterBasedDuration'] : NULL,
'compositionName' => isset($screen['compositionName']) ? $screen['compositionName'] : NULL,
'duration' => isset($screen['duration']) ? $screen['duration'] : NULL,
'extraVideoSecond' => isset($screen['extraVideoSecond']) ? $screen['extraVideoSecond'] : NULL,
'gifBigPath' => isset($screen['gifBigPath']) ? $screen['gifBigPath'] : NULL,
'gifPath' => isset($screen['gifPath']) ? $screen['gifPath'] : NULL,
'gifThumbnailPath' => isset($screen['gifThumbnailPath']) ? $screen['gifThumbnailPath'] : NULL,
'hidden' => isset($screen['hidden']) ? $screen['hidden'] : NULL,
'iconAdjustable' => isset($screen['iconAdjustable']) ? $screen['iconAdjustable'] : NULL,
'isFull' => isset($screen['isFull']) ? $screen['isFull'] : NULL,
'maxDuration' => isset($screen['maxDuration']) ? $screen['maxDuration'] : NULL,
'order' => isset($screen['order']) ? $screen['order'] : NULL,
'path' => isset($screen['path']) ? $screen['path'] : NULL,
'tags' => isset($screen['tags']) ? $screen['tags'] : NULL,
'title' => isset($screen['title']) ? $screen['title'] : NULL,
'type' => isset($screen['type']) ? $screen['type'] : NULL,
'areas' => isset($screen['areas']) ? $screen['areas'] : NULL,
Expand All @@ -345,8 +340,14 @@ public function constructScreen($screen)
}, $screen['areas']);
},
];

return $this->unsetNullProperties($constructedScreen);
$cleanScreen = $this->unsetNullProperties($constructedScreen);
$cleanScreen['compositionName'] = isset($screen['compositionName']) ? $screen['compositionName'] : NULL;
$cleanScreen['gifBigPath'] = isset($screen['gifBigPath']) ? $screen['gifBigPath'] : NULL;
$cleanScreen['gifPath'] = isset($screen['gifPath']) ? $screen['gifPath'] : NULL;
$cleanScreen['gifThumbnailPath'] = isset($screen['gifThumbnailPath']) ? $screen['gifThumbnailPath'] : NULL;
$cleanScreen['tags'] = isset($screen['tags']) ? $screen['tags'] : NULL;

return $cleanScreen;
}

/**
Expand All @@ -362,12 +363,12 @@ public function constructArea($area)
'width' => isset($area['width']) ? $area['width'] : NULL,
'value' => isset($area['value']) ? $area['value'] : NULL,
'cords' => isset($area['cords']) ? $area['cords'] : NULL,
'title' => isset($area['wordCount']) ? $area['wordCount'] : NULL,
'order' => isset($area['order']) ? $area['order'] : NULL,
'type' => isset($area['type']) ? $area['type'] : NULL
];

$result = $this->unsetNullProperties($resultWithNulls);
$result['title'] = isset($area['wordCount']) ? $area['wordCount'] : NULL;

if ($area['type'] === 'text') {
$result['setText'] = function ($text) {
Expand All @@ -378,40 +379,38 @@ public function constructArea($area)

if ($area['type'] === 'image') {
$imageParams = [
'fileName' => isset($area['fileName']) ? $area['fileName'] : NULL,
'originalHeight' => isset($area['originalHeight']) ? $area['originalHeight'] : NULL,
'originalWidth' => isset($area['originalWidth']) ? $area['originalWidth'] : NULL,
'mimeType' => isset($area['mimeType']) ? $area['mimeType'] : NULL,
'webpPath' => isset($area['webpPath']) ? $area['webpPath'] : NULL,
'fileType' => isset($area['fileType']) ? $area['fileType'] : NULL,
'thumbnailPath' => isset($area['thumbnailPath']) ? $area['thumbnailPath'] : NULL,
'imageCropParams' => isset($area['imageCropParams']) ? $area['imageCropParams'] : NULL,
'setImage' => function ($image) use ($area) {
$this->setAreaImage($area, $image);
array_push($this->patchProperties, 'screens');
}
];
$cleanImageParams = $this->unsetNullProperties($imageParams);
$cleanImageParams['fileName'] = isset($area['fileName']) ? $area['fileName'] : NULL;
$cleanImageParams['webpPath'] = isset($area['webpPath']) ? $area['webpPath'] : NULL;
$cleanImageParams['thumbnailPath'] = isset($area['thumbnailPath']) ? $area['thumbnailPath'] : NULL;
$result = array_replace_recursive($result, $cleanImageParams);

$result = array_replace_recursive($result, $this->unsetNullProperties($imageParams));
}

if ($area['type'] === 'video') {
$areaParams = [
'fileName' => isset($area['fileName']) ? $area['fileName'] : NULL,
$videoParams = [
'originalHeight' => isset($area['originalHeight']) ? $area['originalHeight'] : NULL,
'originalWidth' => isset($area['originalWidth']) ? $area['originalWidth'] : NULL,
'mimeType' => isset($area['mimeType']) ? $area['mimeType'] : NULL,
'webpPath' => isset($area['webpPath']) ? $area['webpPath'] : NULL,
'fileType' => isset($area['fileType']) ? $area['fileType'] : NULL,
'thumbnailPath' => isset($area['thumbnailPath']) ? $area['thumbnailPath'] : NULL,
'videoCropParams' => isset($area['videoCropParams']) ? $area['videoCropParams'] : NULL,
'setVideo' => function ($video) use ($area) {
$this->setAreaVideo($area, $video);
array_push($this->patchProperties, 'screens');
}
];

$result = array_replace_recursive($result, $this->unsetNullProperties($areaParams));
$cleanVideoParams = $this->unsetNullProperties($videoParams);
$result = array_replace_recursive($result, $cleanVideoParams);
}

return $result;
Expand All @@ -426,12 +425,9 @@ public function constructArea($area)
public function setAreaImage($area, $image)
{
$imageProperties = [
'fileName' => isset($image['fileName']) ? $image['fileName'] : NULL,
'mimeType' => isset($image['mime']) ? $image['mime'] : NULL,
'value' => isset($image['filePath']) ? $image['filePath'] : NULL,
'webpPath' => isset($image['webpPath']) ? $image['webpPath'] : NULL,
'fileType' => isset($image['fileType']) ? $image['fileType'] : NULL,
'thumbnailPath' => isset($image['thumbnailPath']) ? $image['thumbnailPath'] : NULL,
'imageCropParams' => [
'tranform' => isset($image['imageCropParams']['transform']) ? $image['imageCropParams']['transform'] : NULL,
'top' => isset($image['imageCropParams']['top']) ? $image['imageCropParams']['top'] : NULL,
Expand All @@ -440,8 +436,12 @@ public function setAreaImage($area, $image)
'height' => isset($image['imageCropParams']['height']) ? $image['imageCropParams']['height'] : NULL
]
];
$cleanImageProperties = $this->unsetNullProperties($imageProperties);
$cleanImageProperties['fileName'] = isset($area['fileName']) ? $area['fileName'] : NULL;
$cleanImageProperties['webpPath'] = isset($area['webpPath']) ? $area['webpPath'] : NULL;
$cleanImageProperties['thumbnailPath'] = isset($area['thumbnailPath']) ? $area['thumbnailPath'] : NULL;

return array_replace_recursive($area, $this->unsetNullProperties($imageProperties));
return array_replace_recursive($area, $cleanImageProperties);
}

/**
Expand All @@ -453,14 +453,15 @@ public function setAreaImage($area, $image)
public function setAreaVideo($area, $video)
{
$videoProperties = [
'fileName' => isset($video['fileName']) ? $video['fileName'] : NULL,
'mimeType' => isset($video['mime']) ? $video['mime'] : NULL,
'value' => isset($video['filePath']) ? $video['filePath'] : NULL,
'webpPath' => isset($video['webpPath']) ? $video['webpPath'] : NULL,
'fileType' => isset($video['fileType']) ? $video['fileType'] : NULL,
'videoCropParams' => isset($video['videoCropParams']) ? $video['videoCropParams'] : NULL
];
$cleanVideoProperties = $this->unsetNullProperties($videoProperties);
$cleanVideoProperties['fileName'] = isset($area['fileName']) ? $area['fileName'] : NULL;
$cleanVideoProperties['webpPath'] = isset($area['webpPath']) ? $area['webpPath'] : NULL;

return array_replace_recursive($area, $this->unsetNullProperties($videoProperties));
return array_replace_recursive($area, $cleanVideoProperties);
}
}

0 comments on commit 8150ca7

Please sign in to comment.