src/Entity/PostRecord.php line 16

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PostRecordRepository;
  4. use App\Traits\Timestamps;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassPostRecordRepository::class)]
  8. #[ORM\InheritanceType("SINGLE_TABLE")]
  9. #[ORM\DiscriminatorColumn(name"discr"type"string"length3)]
  10. #[ORM\DiscriminatorMap(["PST"=> PostRecord::class,"STR"=> StoryRecord::class])]
  11. #[ORM\HasLifecycleCallbacks]
  12. class PostRecord
  13. {
  14.     use Timestamps;
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column]
  18.     private ?int $id null;
  19.     #[ORM\ManyToOne(inversedBy'postRecords',cascade: ['persist'])]
  20.     #[ORM\JoinColumn(nullablefalseonDelete"CASCADE")]
  21.     private ?RecordSocialMedia $record null;
  22.     #[ORM\Column(length255nullabletrue)]
  23.     private ?string $type null;
  24.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  25.     private ?\DateTimeInterface $date null;
  26.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  27.     private ?string $message null;
  28.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  29.     private ?string $link null;
  30.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  31.     private ?string $imageLink null;
  32.     /**
  33.      * @var int|null
  34.      * page_posts_reactions on facebook
  35.      */
  36.     #[ORM\Column(nullabletrue)]
  37.     private ?int $likeCount null;
  38.     #[ORM\Column(nullabletrue)]
  39.     private ?int $commentCount null;
  40.     #[ORM\Column(nullabletrue)]
  41.     private ?int $shareCount null;
  42.     #[ORM\Column(nullabletrue)]
  43.     private ?int $engagment null;
  44.     #[ORM\Column(nullabletrue)]
  45.     private ?int $reach null;
  46.     #[ORM\Column(length255nullabletrue)]
  47.     private ?string $reference null;
  48.     #[ORM\Column(nullabletrue)]
  49.     private ?int $twitterQuotes null;
  50.     //reach
  51.     #[ORM\Column(nullabletrue)]
  52.     private ?int $pagePostsImpressionsOrganicUnique null;
  53.     //reach
  54.     #[ORM\Column(nullabletrue)]
  55.     private ?int $pagePostsImpressionsPaidUnique null;
  56.     //impression (facebook , twitter)
  57.     #[ORM\Column(nullabletrue)]
  58.     private ?int $pagePostsImpressionsOrganic null;
  59.     //impression
  60.     #[ORM\Column(nullabletrue)]
  61.     private ?int $pagePostImpressionsPaid null;
  62.     #[ORM\Column(nullabletrue)]
  63.     private ?int $facebookVideoViewsTotal null;
  64.     #[ORM\Column(nullabletrue)]
  65.     private ?int $facebookVideoViewscompleteTotal null;
  66.     #[ORM\Column(nullabletrue)]
  67.     private ?int $facebookVideoViewTime null;
  68.     #[ORM\Column(nullabletrue)]
  69.     private ?int $facebookReelViewsTotal null;
  70.     #[ORM\Column(nullabletrue)]
  71.     private ?int $facebookReelViewsCompleteTotal null;
  72.     /**
  73.      * @var int|null
  74.      * page_link_video_clicks_count on facebook
  75.      */
  76.     #[ORM\Column(nullabletrue)]
  77.     private ?int $pageLinkVideoClicksCount null;
  78.     #[ORM\Column(nullabletrue)]
  79.     private ?int $pagePostsImpressionsUnique null;
  80.     #[ORM\Column(length255nullabletrue)]
  81.     private ?string $totalInteraction null;
  82.     #[ORM\Column(length255nullabletrue)]
  83.     private ?string $pagePostsImpressions null;
  84.     #[ORM\Column(length255nullabletrue)]
  85.     private ?string $tweetsUrlLinkClicks null;
  86.     #[ORM\Column(length255nullabletrue)]
  87.     private ?string $tweetsUserProfileClicks null;
  88.     #[ORM\Column(length255nullabletrue)]
  89.     private ?string $tweetsRetweets null;
  90.     #[ORM\Column(length255nullabletrue)]
  91.     private ?string $saveCount null;
  92.     #[ORM\Column(nullabletrue)]
  93.     private ?int $profilePostVideoViewsTotal null;
  94.     #[ORM\Column(nullabletrue)]
  95.     private ?int $profilePostReplays null;
  96.     #[ORM\Column(nullabletrue)]
  97.     private ?int $profilePostPlays null;
  98.     #[ORM\Column(nullabletrue)]
  99.     private ?int $profilePostReelsViewTotalTime null;
  100.     //for youtube
  101.     #[ORM\Column(length255nullabletrue)]
  102.     private ?string $channelDislikesCount null;
  103.     //for youtube
  104.     #[ORM\Column(length255nullabletrue)]
  105.     private ?string $channelVideosVideoViewCount null;
  106.     //for youtube
  107.     #[ORM\Column(length255nullabletrue)]
  108.     private ?string $channelShortsVideoViewCount null;
  109.     #[ORM\Column(length255nullabletrue)]
  110.     private ?string $facebookVideoViews10s null;
  111.     #[ORM\Column(length255nullabletrue)]
  112.     private ?string $mediaViews null;
  113.     #[ORM\Column(length255nullabletrue)]
  114.     private ?string $tiktokerPostReach null;
  115.     #[ORM\Column(length255nullabletrue)]
  116.     private ?string $tiktokerPostTotalTimeWatched null;
  117.     public function getId(): ?int
  118.     {
  119.         return $this->id;
  120.     }
  121.     public function getRecord(): ?RecordSocialMedia
  122.     {
  123.         return $this->record;
  124.     }
  125.     public function setRecord(?RecordSocialMedia $record): static
  126.     {
  127.         $this->record $record;
  128.         return $this;
  129.     }
  130.     public function getType(): ?string
  131.     {
  132.         return $this->type;
  133.     }
  134.     public function setType(?string $type): static
  135.     {
  136.         $this->type $type;
  137.         return $this;
  138.     }
  139.     public function getDate(): ?\DateTimeInterface
  140.     {
  141.         return $this->date;
  142.     }
  143.     public function setDate(\DateTimeInterface $date): static
  144.     {
  145.         $this->date $date;
  146.         return $this;
  147.     }
  148.     public function getMessage(): ?string
  149.     {
  150.         return $this->message;
  151.     }
  152.     public function setMessage(?string $message): static
  153.     {
  154.         $this->message $message;
  155.         return $this;
  156.     }
  157.     public function getLink(): ?string
  158.     {
  159.         return $this->link;
  160.     }
  161.     public function setLink(?string $link): static
  162.     {
  163.         $this->link $link;
  164.         return $this;
  165.     }
  166.     public function getImageLink(): ?string
  167.     {
  168.         return $this->imageLink;
  169.     }
  170.     public function setImageLink(?string $imageLink): static
  171.     {
  172.         $this->imageLink $imageLink;
  173.         return $this;
  174.     }
  175.     public function getLikeCount(): ?int
  176.     {
  177.         return $this->likeCount;
  178.     }
  179.     public function setLikeCount(?int $likeCount): static
  180.     {
  181.         $this->likeCount $likeCount;
  182.         return $this;
  183.     }
  184.     public function getCommentCount(): ?int
  185.     {
  186.         return $this->commentCount;
  187.     }
  188.     public function setCommentCount(?int $commentCount): static
  189.     {
  190.         $this->commentCount $commentCount;
  191.         return $this;
  192.     }
  193.     public function getShareCount(): ?int
  194.     {
  195.         return $this->shareCount;
  196.     }
  197.     public function setShareCount(?int $shareCount): static
  198.     {
  199.         $this->shareCount $shareCount;
  200.         return $this;
  201.     }
  202.     public function getEngagment(): ?int
  203.     {
  204.         return $this->engagment;
  205.     }
  206.     public function setEngagment(?int $engagment): static
  207.     {
  208.         $this->engagment $engagment;
  209.         return $this;
  210.     }
  211.     public function getReach(): ?int
  212.     {
  213.         return $this->reach;
  214.     }
  215.     public function setReach(?int $reach): static
  216.     {
  217.         $this->reach $reach;
  218.         return $this;
  219.     }
  220.     /**
  221.      * @return int|null
  222.      */
  223.     public function getInteractionSum(): ?int
  224.     {
  225.         return $this->likeCount $this->commentCount $this->shareCount $this->saveCount;
  226.     }
  227.     public function getReference(): ?string
  228.     {
  229.         return $this->reference;
  230.     }
  231.     public function setReference(?string $reference): static
  232.     {
  233.         $this->reference $reference;
  234.         return $this;
  235.     }
  236.     public function getTwitterQuotes(): ?int
  237.     {
  238.         return $this->twitterQuotes;
  239.     }
  240.     public function setTwitterQuotes(?int $twitterQuotes): static
  241.     {
  242.         $this->twitterQuotes $twitterQuotes;
  243.         return $this;
  244.     }
  245.     public function getPagePostsImpressionsOrganicUnique(): ?int
  246.     {
  247.         return $this->pagePostsImpressionsOrganicUnique;
  248.     }
  249.     public function setPagePostsImpressionsOrganicUnique(?int $pagePostsImpressionsOrganicUnique): static
  250.     {
  251.         $this->pagePostsImpressionsOrganicUnique $pagePostsImpressionsOrganicUnique;
  252.         return $this;
  253.     }
  254.     public function getPagePostsImpressionsPaidUnique(): ?int
  255.     {
  256.         return $this->pagePostsImpressionsPaidUnique;
  257.     }
  258.     public function setPagePostsImpressionsPaidUnique(?int $pagePostsImpressionsPaidUnique): static
  259.     {
  260.         $this->pagePostsImpressionsPaidUnique $pagePostsImpressionsPaidUnique;
  261.         return $this;
  262.     }
  263.     public function getPagePostsImpressionsOrganic(): ?int
  264.     {
  265.         return $this->pagePostsImpressionsOrganic;
  266.     }
  267.     public function setPagePostsImpressionsOrganic(?int $pagePostsImpressionsOrganic): static
  268.     {
  269.         $this->pagePostsImpressionsOrganic $pagePostsImpressionsOrganic;
  270.         return $this;
  271.     }
  272.     public function getPagePostImpressionsPaid(): ?int
  273.     {
  274.         return $this->pagePostImpressionsPaid;
  275.     }
  276.     public function setPagePostImpressionsPaid(?int $pagePostImpressionsPaid): static
  277.     {
  278.         $this->pagePostImpressionsPaid $pagePostImpressionsPaid;
  279.         return $this;
  280.     }
  281.     public function getFacebookVideoViewsTotal(): ?int
  282.     {
  283.         return $this->facebookVideoViewsTotal;
  284.     }
  285.     public function setFacebookVideoViewsTotal(?int $facebookVideoViewsTotal): static
  286.     {
  287.         $this->facebookVideoViewsTotal $facebookVideoViewsTotal;
  288.         return $this;
  289.     }
  290.     public function getFacebookVideoViewscompleteTotal(): ?int
  291.     {
  292.         return $this->facebookVideoViewscompleteTotal;
  293.     }
  294.     public function setFacebookVideoViewscompleteTotal(?int $facebookVideoViewscompleteTotal): static
  295.     {
  296.         $this->facebookVideoViewscompleteTotal $facebookVideoViewscompleteTotal;
  297.         return $this;
  298.     }
  299.     public function getFacebookVideoViewTime(): ?int
  300.     {
  301.         return $this->facebookVideoViewTime;
  302.     }
  303.     public function setFacebookVideoViewTime(?int $facebookVideoViewTime): static
  304.     {
  305.         $this->facebookVideoViewTime $facebookVideoViewTime;
  306.         return $this;
  307.     }
  308.     public function getFacebookReelViewsTotal(): ?int
  309.     {
  310.         return $this->facebookReelViewsTotal;
  311.     }
  312.     public function setFacebookReelViewsTotal(?int $facebookReelViewsTotal): static
  313.     {
  314.         $this->facebookReelViewsTotal $facebookReelViewsTotal;
  315.         return $this;
  316.     }
  317.     public function getFacebookReelViewsCompleteTotal(): ?int
  318.     {
  319.         return $this->facebookReelViewsCompleteTotal;
  320.     }
  321.     public function setFacebookReelViewsCompleteTotal(?int $facebookReelViewsCompleteTotal): static
  322.     {
  323.         $this->facebookReelViewsCompleteTotal $facebookReelViewsCompleteTotal;
  324.         return $this;
  325.     }
  326.     public function getPageLinkVideoClicksCount(): ?int
  327.     {
  328.         return $this->pageLinkVideoClicksCount;
  329.     }
  330.     public function setPageLinkVideoClicksCount(?int $pageLinkVideoClicksCount): static
  331.     {
  332.         $this->pageLinkVideoClicksCount $pageLinkVideoClicksCount;
  333.         return $this;
  334.     }
  335.     public function getPagePostsImpressionsUnique(): ?int
  336.     {
  337.         return $this->pagePostsImpressionsUnique;
  338.     }
  339.     public function setPagePostsImpressionsUnique(?int $pagePostsImpressionsUnique): static
  340.     {
  341.         $this->pagePostsImpressionsUnique $pagePostsImpressionsUnique;
  342.         return $this;
  343.     }
  344.     public function isStory(): bool
  345.     {
  346.         return $this->getType() === 'STORY';
  347.     }
  348.     public function getTotalInteraction(): ?string
  349.     {
  350.         return $this->totalInteraction;
  351.     }
  352.     public function setTotalInteraction(?string $totalInteraction): static
  353.     {
  354.         $this->totalInteraction $totalInteraction;
  355.         return $this;
  356.     }
  357.     public function getPagePostsImpressions(): ?string
  358.     {
  359.         return $this->pagePostsImpressions;
  360.     }
  361.     public function setPagePostsImpressions(?string $pagePostsImpressions): static
  362.     {
  363.         $this->pagePostsImpressions $pagePostsImpressions;
  364.         return $this;
  365.     }
  366.     public function getTweetsUrlLinkClicks(): ?string
  367.     {
  368.         return $this->tweetsUrlLinkClicks;
  369.     }
  370.     public function setTweetsUrlLinkClicks(?string $tweetsUrlLinkClicks): static
  371.     {
  372.         $this->tweetsUrlLinkClicks $tweetsUrlLinkClicks;
  373.         return $this;
  374.     }
  375.     public function getTweetsUserProfileClicks(): ?string
  376.     {
  377.         return $this->tweetsUserProfileClicks;
  378.     }
  379.     public function setTweetsUserProfileClicks(?string $tweetsUserProfileClicks): static
  380.     {
  381.         $this->tweetsUserProfileClicks $tweetsUserProfileClicks;
  382.         return $this;
  383.     }
  384.     public function getTweetsRetweets(): ?string
  385.     {
  386.         return $this->tweetsRetweets;
  387.     }
  388.     public function setTweetsRetweets(?string $tweetsRetweets): static
  389.     {
  390.         $this->tweetsRetweets $tweetsRetweets;
  391.         return $this;
  392.     }
  393.     public function getSaveCount(): ?string
  394.     {
  395.         return $this->saveCount;
  396.     }
  397.     public function setSaveCount(?string $saveCount): static
  398.     {
  399.         $this->saveCount $saveCount;
  400.         return $this;
  401.     }
  402.     public function getProfilePostVideoViewsTotal(): ?int
  403.     {
  404.         return $this->profilePostVideoViewsTotal;
  405.     }
  406.     public function setProfilePostVideoViewsTotal(?int $profilePostVideoViewsTotal): static
  407.     {
  408.         $this->profilePostVideoViewsTotal $profilePostVideoViewsTotal;
  409.         return $this;
  410.     }
  411.     public function getProfilePostReplays(): ?int
  412.     {
  413.         return $this->profilePostReplays;
  414.     }
  415.     public function setProfilePostReplays(?int $profilePostReplays): static
  416.     {
  417.         $this->profilePostReplays $profilePostReplays;
  418.         return $this;
  419.     }
  420.     public function getProfilePostPlays(): ?int
  421.     {
  422.         return $this->profilePostPlays;
  423.     }
  424.     public function setProfilePostPlays(?int $profilePostPlays): static
  425.     {
  426.         $this->profilePostPlays $profilePostPlays;
  427.         return $this;
  428.     }
  429.     public function getProfilePostReelsViewTotalTime(): ?int
  430.     {
  431.         return $this->profilePostReelsViewTotalTime;
  432.     }
  433.     public function setProfilePostReelsViewTotalTime(?int $profilePostReelsViewTotalTime): static
  434.     {
  435.         $this->profilePostReelsViewTotalTime $profilePostReelsViewTotalTime;
  436.         return $this;
  437.     }
  438.     public function getPagePostsImpressionsOrganicAndPaid():?int
  439.     {
  440.         return $this->getPagePostsImpressionsOrganic() + $this->getPagePostImpressionsPaid();
  441.     }
  442.     /**
  443.      * @return int|string|null
  444.      */
  445.     public function getTwitterInteractions(): int|string|null
  446.     {
  447.         return $this->getLikeCount() + $this->getTweetsUrlLinkClicks() + $this->getTweetsUserProfileClicks() + $this->getTwitterQuotes() + $this->getTweetsRetweets() + $this->getCommentCount();
  448.     }
  449.     public function getChannelDislikesCount(): ?string
  450.     {
  451.         return $this->channelDislikesCount;
  452.     }
  453.     public function setChannelDislikesCount(?string $channelDislikesCount): static
  454.     {
  455.         $this->channelDislikesCount $channelDislikesCount;
  456.         return $this;
  457.     }
  458.     public function getChannelVideosVideoViewCount(): ?string
  459.     {
  460.         return $this->channelVideosVideoViewCount;
  461.     }
  462.     public function setChannelVideosVideoViewCount(?string $channelVideosVideoViewCount): static
  463.     {
  464.         $this->channelVideosVideoViewCount $channelVideosVideoViewCount;
  465.         return $this;
  466.     }
  467.     public function getChannelShortsVideoViewCount(): ?string
  468.     {
  469.         return $this->channelShortsVideoViewCount;
  470.     }
  471.     public function setChannelShortsVideoViewCount(?string $channelShortsVideoViewCount): static
  472.     {
  473.         $this->channelShortsVideoViewCount $channelShortsVideoViewCount;
  474.         return $this;
  475.     }
  476.     public function getTotalInteractionYoutube():?string
  477.     {
  478.         return  $this->channelDislikesCount $this->likeCount $this->commentCount;
  479.     }
  480.     public function isShort(): bool
  481.     {
  482.         return $this->getType() === 'SHORTS';
  483.     }
  484.     /**
  485.      * @return int|string|null
  486.      */
  487.     public function getTotalInteractions(): int|string|null
  488.     {
  489.         return match ($this->getRecord()->getNetwork()) {
  490.             SocialMedia::NETWORK_YOUTUBE => $this->getTotalInteractionYoutube(),
  491.             SocialMedia::NETWORK_TWITTER => $this->getTwitterInteractions(),
  492.             default => $this->getLikeCount()+ $this->getShareCount() + $this->getSaveCount()+ $this->getCommentCount()
  493.         };
  494.     }
  495.     /**
  496.      * @return int|null
  497.      */
  498.     public function getSumInstagramEngagement():?int
  499.     {
  500.         return $this->getSaveCount() + $this->getShareCount() + $this->getLikeCount() + $this->getCommentCount();
  501.     }
  502.     /**
  503.      * @return int|null
  504.      */
  505.     public function getTotalEngagement(): ?int
  506.     {
  507.         return match ($this->getRecord()->getNetwork()) {
  508.             SocialMedia::NETWORK_INSTAGRAM => $this->getSumInstagramEngagement(),
  509.             SocialMedia::NETWORK_YOUTUBE => $this->getTotalInteractionYoutube(),
  510.             SocialMedia::NETWORK_TWITTER => $this->getEngagementTwitter(),
  511.             SocialMedia::NETWORK_TIKTOK => $this->getEngagementTiktok(),
  512.             default => $this->getCommentCount() +$this->getShareCount() + $this->getLikeCount() + $this->getPageLinkVideoClicksCount()
  513.         };
  514.     }
  515.     /**
  516.      * @return int|string|null
  517.      */
  518.     public function getEngagementTwitter(): int|string|null
  519.     {
  520.       return $this->getTweetsUrlLinkClicks() + $this->getTweetsUserProfileClicks() + $this->getTweetsRetweets() + $this->getTwitterQuotes() + $this->getLikeCount() + $this->getCommentCount();
  521.     }
  522.     /**
  523.      * @return int|string|null
  524.      */
  525.     public function getTotalImpression(): int|string|null
  526.     {
  527.         return match ($this->getRecord()->getNetwork()) {
  528.             SocialMedia::NETWORK_INSTAGRAMSocialMedia::NETWORK_YOUTUBE => $this->getPagePostsImpressions(),
  529.             default => $this->getPagePostsImpressionsOrganic() + $this->getPagePostImpressionsPaid(),
  530.         };
  531.     }
  532.     public function getFacebookVideoViews10s(): ?string
  533.     {
  534.         return $this->facebookVideoViews10s;
  535.     }
  536.     public function setFacebookVideoViews10s(?string $facebookVideoViews10s): static
  537.     {
  538.         $this->facebookVideoViews10s $facebookVideoViews10s;
  539.         return $this;
  540.     }
  541.     public function getMediaViews(): ?string
  542.     {
  543.         return $this->mediaViews;
  544.     }
  545.     public function setMediaViews(?string $mediaViews): static
  546.     {
  547.         $this->mediaViews $mediaViews;
  548.         return $this;
  549.     }
  550.     public function getTiktokerPostReach(): ?string
  551.     {
  552.         return $this->tiktokerPostReach;
  553.     }
  554.     public function setTiktokerPostReach(?string $tiktokerPostReach): static
  555.     {
  556.         $this->tiktokerPostReach $tiktokerPostReach;
  557.         return $this;
  558.     }
  559.     public function getTiktokerPostTotalTimeWatched(): ?string
  560.     {
  561.         return $this->tiktokerPostTotalTimeWatched;
  562.     }
  563.     public function setTiktokerPostTotalTimeWatched(?string $tiktokerPostTotalTimeWatched): static
  564.     {
  565.         $this->tiktokerPostTotalTimeWatched $tiktokerPostTotalTimeWatched;
  566.         return $this;
  567.     }
  568.     public function getEngagementTiktok(): ?int
  569.     {
  570.         return $this->getCommentCount() +$this->getShareCount() + $this->getLikeCount();
  571.     }
  572. }