<?php

namespace App\Entity\Campaign;

use App\Entity\Campaign;
use App\Entity\Traits\TimestampableTrait;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity()
 */
class PageSpeedCheck
{
    use TimestampableTrait;

    /**
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\ManyToOne(targetEntity="App\Entity\Campaign", inversedBy="pageSpeedChecks")
     * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
     */
    private $campaign;

    /**
     * @ORM\Column(type="integer")
     */
    private $desktopScore;

    /**
     * @ORM\Column(type="integer")
     */
    private $mobileScore;

    /**
     * @ORM\Column(type="text")
     */
    private $desktopResult;

    /**
     * @ORM\Column(type="text")
     */
    private $mobileResult;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getCampaign(): ?Campaign
    {
        return $this->campaign;
    }

    public function setCampaign(?Campaign $campaign): self
    {
        $this->campaign = $campaign;
        $campaign->setLatestPageSpeedCheck($this);

        return $this;
    }

    public function getDesktopScore(): ?int
    {
        return $this->desktopScore;
    }

    public function setDesktopScore(int $desktopScore): self
    {
        $this->desktopScore = $desktopScore;

        return $this;
    }

    public function getMobileScore(): ?int
    {
        return $this->mobileScore;
    }

    public function setMobileScore(int $mobileScore): self
    {
        $this->mobileScore = $mobileScore;

        return $this;
    }

    public function getDesktopResult(): ?array
    {
        return json_decode($this->desktopResult, true);
    }

    public function setDesktopResult(string $desktopResult): self
    {
        $this->desktopResult = $desktopResult;

        return $this;
    }

    public function getMobileResult(): ?array
    {
        return json_decode($this->mobileResult, true);
    }

    public function setMobileResult(string $mobileResult): self
    {
        $this->mobileResult = $mobileResult;

        return $this;
    }
}
