<?php
namespace Sq\Entity\Schema\ORM;
use Doctrine\ORM\Mapping as ORM;
/**
* IosApp.
*/
#[ORM\Entity]
#[ORM\Table(name: 'ios_app')]
#[ORM\UniqueConstraint(name: 'unique_ios', columns: ['ios_m_id', 'ios_device_token'])]
class IosApp implements MobileAppInterface
{
/**
* @var int
*/
#[ORM\Column(name: 'ios_id', type: 'integer', nullable: false, options: ['unsigned' => true])]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
private $id;
/**
* @var Member|null
*/
#[ORM\ManyToOne(targetEntity: Member::class, inversedBy: 'iosApps')]
#[ORM\JoinColumn(name: 'ios_m_id', referencedColumnName: 'm_id', nullable: true)]
private $member;
/**
*
* @var Organization|null
*
* @deprecated To be removed.
*/
#[ORM\Column(name: 'ios_o_id', type: 'integer', nullable: true)]
private $deprecatedOrganization;
/**
*
* @var User|null
*/
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'iosApps')]
#[ORM\JoinColumn(name: 'ios_u_id', referencedColumnName: 'u_id', nullable: true)]
private $user;
/**
* @var string|null
*/
#[ORM\Column(name: 'ios_device_token', type: 'string', length: 64, nullable: true)]
private $deviceToken;
/**
* @var string|null
*/
#[ORM\Column(name: 'ios_endpoint_arn', type: 'string', length: 255, nullable: true)]
private $endpointArn;
/**
* @var \DateTime|null
*/
#[ORM\Column(name: 'ios_token_first_added', type: 'datetime', nullable: true, options: ['default' => '0000-00-00 00:00:00'])]
private $firstConnectedTime;
/**
* @var \DateTime|null
*/
#[ORM\Column(name: 'ios_token_last_updated', type: 'datetime', nullable: true, options: ['default' => '0000-00-00 00:00:00'])]
private $lastConnectedTime;
/**
* @var string|null
*/
#[ORM\Column(name: 'ios_build', type: 'string', length: 10, nullable: true)]
private $build;
/**
* @var string|null
*/
#[ORM\Column(name: 'ios_device_type', type: 'string', length: 64, nullable: true)]
private $deviceType;
/**
* @var string|null
*/
#[ORM\Column(name: 'ios_device_name', type: 'string', length: 64, nullable: true)]
private $deviceName;
public function __construct(
User $user,
string $endpointArn,
string $apnDeviceToken,
int $buildCode,
?string $deviceType = null,
?string $deviceName = null,
) {
$this->user = $user;
$this->deviceToken = $apnDeviceToken;
$this->endpointArn = $endpointArn;
$this->build = $buildCode;
$this->deviceType = $deviceType;
$this->deviceName = $deviceName;
$this->firstConnectedTime = new \DateTime();
$this->lastConnectedTime = new \DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getMember(): ?Member
{
return $this->member;
}
public function getUser(): User
{
return $this->user;
}
public function getDeviceToken(): string
{
return $this->deviceToken;
}
public function getEndpointArn(): ?string
{
return $this->endpointArn;
}
public function updateEndpointArn(?string $endpointArn): static
{
$this->endpointArn = $endpointArn;
$this->lastConnectedTime = new \DateTime();
return $this;
}
public function getFirstConnectedTime(): \DateTimeInterface
{
return $this->firstConnectedTime;
}
public function getLastConnectedTime(): \DateTimeInterface
{
return $this->lastConnectedTime;
}
public function getBuildNumber(): int
{
return (int) $this->build;
}
public function updateBuildNumber(int $buildNumber): static
{
$this->build = '' . $buildNumber;
return $this;
}
public function getDeviceType(): ?string
{
return $this->deviceType;
}
public function getDeviceName(): ?string
{
return $this->deviceName;
}
public function updateDeviceName(string $deviceName): static
{
$this->deviceName = $deviceName;
return $this;
}
public function isConnected(): bool
{
return $this->endpointArn !== null;
}
/**
* Check if they have a valid connected app (with notifications still working), and the app is recent enough to support video & carousel posts.
*
* @return bool
*/
public function isVideoCarouselSupported(): bool
{
global $arr_config;
return $this->build >= $arr_config['ios_video_carousel_min_build'] && $this->endpointArn != "";
}
/**
* Check if they have a valid connected app (with notifications still working), and the app is recent enough to support Generic Profiles.
*
* @return bool
*/
public function isGenericProfileSupported(): bool
{
global $arr_config;
return $this->build >= $arr_config['ios_generic_profiles_min_build'] && $this->endpointArn != "";
}
}