Reducing complexity of method
You could remove some duplication with a getPortraitValue function:

function getPortraitValue($apiData, $key) {
    $portrait = $apiData['portrait'];
    if (isset($portrait[$key])) {
        return $portrait[$key];
    }
    return null;
}

$portrait = new Portrait();
$portrait-&gt;setXCoordinate(getPortraitValue($apiData, 'x')
    -&gt;setYCoordinate(getPortraitValue($apiData, 'y'))
    -&gt;setWidth(getPortraitValue($apiData, 'w'))
    -&gt;setHeight(getPortraitValue($apiData, 'h'))
    -&gt;setOffset(getPortraitValue($apiData, 'offset')
    -&gt;setUrl(getPortraitValue($apiData, 'url');
return $portrait;