protected $default_profile;
/** @var bool */
protected $default_profile_image;
- /** @var Status */
+ /** @var array */
protected $status;
/** @var array */
protected $withheld_in_countries;
* @param array $publicContact Full contact table record with uid = 0
* @param array $apcontact Optional full apcontact table record
* @param array $userContact Optional full contact table record with uid != 0
- * @param null $status
+ * @param array $status
* @param bool $include_user_entities Whether to add the entities property
*
* @throws InternalServerErrorException
*/
- public function __construct(array $publicContact, array $apcontact = [], array $userContact = [], $status = null, bool $include_user_entities = true)
+ public function __construct(array $publicContact, array $apcontact = [], array $userContact = [], ?array $status = null, bool $include_user_entities = true)
{
$uid = $userContact['uid'] ?? 0;
$this->default_profile = false;
$this->default_profile_image = false;
- if (!empty($status)) {
+ if (is_array($status)) {
$this->status = $status;
} else {
unset($this->status);
public function getBlurHash(): string
{
$image = New Image($this->asString(), $this->getType(), $this->filename, false);
- if (empty($image) || !$this->isValid()) {
+ if (!$this->isValid()) {
return '';
}
{
$scaled = Images::getScalingDimensions($width, $height, 90);
$pixels = Blurhash::decode($blurhash, $scaled['width'], $scaled['height']);
+ $draw = null;
if ($this->isImagick()) {
$this->image = new Imagick();
for ($y = 0; $y < $scaled['height']; ++$y) {
for ($x = 0; $x < $scaled['width']; ++$x) {
[$r, $g, $b] = $pixels[$y][$x];
- if ($this->isImagick()) {
+ if ($draw !== null) {
$draw->setFillColor("rgb($r, $g, $b)");
$draw->point($x, $y);
} else {
}
}
- if ($this->isImagick()) {
+ if ($draw !== null) {
$this->image->drawImage($draw);
$this->width = $this->image->getImageWidth();
$this->height = $this->image->getImageHeight();