app/Entity/Schema/ORM/Plan.php line 16

Open in your IDE?
  1. <?php
  2. namespace Sq\Entity\Schema\ORM;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Sq\Entity\Enum;
  7. use Sq\Entity\Schema\Column;
  8. /**
  9.  * Plan.
  10.  */
  11. #[ORM\Entity]
  12. #[ORM\Table(name'plan')]
  13. class Plan
  14. {
  15.     /**
  16.      * @var int
  17.      */
  18.     #[ORM\Column(name'plan_id'type'smallint'precision0scale0nullablefalseoptions: ['unsigned' => true], uniquefalse)]
  19.     #[ORM\Id]
  20.     #[ORM\GeneratedValue(strategy'IDENTITY')]
  21.     private $id;
  22.     /**
  23.      * @var string|null
  24.      */
  25.     #[ORM\Column(name'plan_name'type'string'length32precision0scale0nullabletrueuniquefalse)]
  26.     private $name;
  27.     /**
  28.      * @var string|null
  29.      */
  30.     #[ORM\Column(name'plan_type'type'string'length0nullablefalseoptions: ['default' => 'agency'])]
  31.     private $type Column\PlanType::AGENCY;
  32.     /**
  33.      * @var string|null
  34.      */
  35.     #[ORM\Column(name'plan_tagline'type'string'length255precision0scale0nullabletrueuniquefalse)]
  36.     private $tagline;
  37.     /**
  38.      * @var string|null
  39.      */
  40.     #[ORM\Column(name'plan_notes'type'text'length255precision0scale0nullabletrueuniquefalse)]
  41.     private $notes;
  42.     /**
  43.      * @var string|null
  44.      */
  45.     #[ORM\Column(name'plan_price_monthly_gbp'type'decimal'precision8scale2nullabletrueuniquefalse)]
  46.     private $priceMonthlyGbp;
  47.     /**
  48.      * @var string|null
  49.      */
  50.     #[ORM\Column(name'plan_price_yearly_gbp'type'decimal'precision8scale2nullabletrueuniquefalse)]
  51.     private $priceYearlyGbp;
  52.     /**
  53.      * @var string|null
  54.      */
  55.     #[ORM\Column(name'plan_price_monthly_usd'type'decimal'precision8scale2nullabletrueuniquefalse)]
  56.     private $priceMonthlyUsd;
  57.     /**
  58.      * @var string|null
  59.      */
  60.     #[ORM\Column(name'plan_price_yearly_usd'type'decimal'precision8scale2nullabletrueuniquefalse)]
  61.     private $priceYearlyUsd;
  62.     /**
  63.      * @var string|null
  64.      */
  65.     #[ORM\Column(name'plan_price_monthly_eur'type'decimal'precision8scale2nullabletrueuniquefalse)]
  66.     private $priceMonthlyEur;
  67.     /**
  68.      * @var string|null
  69.      */
  70.     #[ORM\Column(name'plan_price_yearly_eur'type'decimal'precision8scale2nullabletrueuniquefalse)]
  71.     private $priceYearlyEur;
  72.     /**
  73.      * @var int|null
  74.      */
  75.     #[ORM\Column(name'plan_limit_accounts'type'smallint'precision0scale0nullabletrueoptions: ['unsigned' => true], uniquefalse)]
  76.     private $limitAccounts;
  77.     /**
  78.      * @var int|null
  79.      */
  80.     #[ORM\Column(name'plan_limit_posts'type'smallint'precision0scale0nullabletrueoptions: ['unsigned' => true], uniquefalse)]
  81.     private $limitPosts;
  82.     /**
  83.      * @var int|null
  84.      */
  85.     #[ORM\Column(name'plan_limit_users'type'smallint'precision0scale0nullabletrueoptions: ['unsigned' => true], uniquefalse)]
  86.     private $limitUsers;
  87.     /**
  88.      * @var int|null
  89.      */
  90.     #[ORM\Column(name'plan_limit_workspaces'type'smallint'precision0scale0nullabletrueoptions: ['unsigned' => true], uniquefalse)]
  91.     private $limitWorkspaces;
  92.     /**
  93.      * @var int|null
  94.      */
  95.     #[ORM\Column(name'plan_limit_timeslots'type'smallint'precision0scale0nullabletrueoptions: ['unsigned' => true], uniquefalse)]
  96.     private $limitTimeslots;
  97.     /**
  98.      * @var int|null
  99.      */
  100.     #[ORM\Column(name'plan_limit_categories'type'smallint'precision0scale0nullabletrueoptions: ['unsigned' => true], uniquefalse)]
  101.     private $limitCategories;
  102.     /**
  103.      * @var int|null
  104.      */
  105.     #[ORM\Column(name'plan_limit_importer'type'smallint'nullabletrueuniquefalse)]
  106.     private $limitImporter;
  107.     /**
  108.      * @var int|null
  109.      */
  110.     #[ORM\Column(name'plan_limit_auto_rss'type'integer'precision0scale0nullabletrueoptions: ['default' => '1''unsigned' => true], uniquefalse)]
  111.     private $limitAutoRss '1';
  112.     /**
  113.      * @var int|null
  114.      */
  115.     #[ORM\Column(name'plan_limit_analytics'type'smallint'nullabletrueuniquefalse)]
  116.     private $limitAnalytics;
  117.     /**
  118.      * @var int|null
  119.      */
  120.     #[ORM\Column(name'plan_limit_ai_text'type'integer'precision0scale0nullablefalseoptions: ['default' => '5000''unsigned' => true], uniquefalse)]
  121.     private $limitAiText '5000';
  122.     /**
  123.      * @var int|null
  124.      */
  125.     #[ORM\Column(name'plan_limit_weekly_tweet_cap'type'integer'precision0scale0nullablefalseoptions: ['default' => '5''unsigned' => true], uniquefalse)]
  126.     private $limitWeeklyTweetCap '5';
  127.     /**
  128.      * @var Collection<int, PlanGroup>
  129.      */
  130.     #[ORM\OneToMany(targetEntityPlanGroup::class, mappedBy'plan')]
  131.     private $planGroups;
  132.     public function __construct()
  133.     {
  134.         $this->planGroups = new ArrayCollection();
  135.     }
  136.     public function getId()
  137.     {
  138.         return $this->id;
  139.     }
  140.     public function getName()
  141.     {
  142.         return $this->name;
  143.     }
  144.     public function getType(): Enum\Plan\PlanType
  145.     {
  146.         $type = match ($this->type)
  147.         {
  148.             Column\PlanType::SOLO => Enum\Plan\PlanType::SOLO(),
  149.             Column\PlanType::BUSINESS => Enum\Plan\PlanType::BUSINESS(),
  150.             Column\PlanType::AGENCY => Enum\Plan\PlanType::AGENCY(),
  151.             Column\PlanType::LITE => Enum\Plan\PlanType::LITE()
  152.         };
  153.         $type === null && throw new \RuntimeException('getType() type invalid');
  154.         return $type;
  155.     }
  156.     public function getTagline()
  157.     {
  158.         return $this->tagline;
  159.     }
  160.     public function getNotes()
  161.     {
  162.         return $this->notes;
  163.     }
  164.     public function getPriceMonthlyGbp(): ?string
  165.     {
  166.         return $this->priceMonthlyGbp;
  167.     }
  168.     public function getPriceYearlyGbp(): ?string
  169.     {
  170.         return $this->priceYearlyGbp;
  171.     }
  172.     public function getPriceMonthlyUsd(): ?string
  173.     {
  174.         return $this->priceMonthlyUsd;
  175.     }
  176.     public function getPriceYearlyUsd(): ?string
  177.     {
  178.         return $this->priceYearlyUsd;
  179.     }
  180.     public function getPriceMonthlyEur(): ?string
  181.     {
  182.         return $this->priceMonthlyEur;
  183.     }
  184.     public function getPriceYearlyEur(): ?string
  185.     {
  186.         return $this->priceYearlyEur;
  187.     }
  188.     /**
  189.      * @deprecated - (Not really deprecated, but to mark it).
  190.      *
  191.      * @use \Sq\Service\Plan\MemberPlanLimits::getPlanLimitAccounts() instead (to include addons).
  192.      */
  193.     public function getLimitAccounts()
  194.     {
  195.         return $this->limitAccounts;
  196.     }
  197.     /**
  198.      * @deprecated - (Not really deprecated, but to mark it).
  199.      *
  200.      * @use \Sq\Service\Plan\MemberPlanLimits::getPlanLimitPosts() instead (to include addons).
  201.      */
  202.     public function getLimitPosts()
  203.     {
  204.         return $this->limitPosts;
  205.     }
  206.     /**
  207.      * @deprecated - (Not really deprecated, but to mark it).
  208.      *
  209.      * @use \Sq\Service\Plan\MemberPlanLimits::getPlanLimitUsers() instead (to include addons).
  210.      */
  211.     public function getLimitUsers()
  212.     {
  213.         return $this->limitUsers;
  214.     }
  215.     /**
  216.      * @deprecated - (Not really deprecated, but to mark it).
  217.      *
  218.      * @use \Sq\Service\Plan\MemberPlanLimits::getPlanLimitWorkspaces() instead (to include addons).
  219.      */
  220.     public function getLimitWorkspaces()
  221.     {
  222.         return $this->limitWorkspaces;
  223.     }
  224.     /**
  225.      * @deprecated - (Not really deprecated, but to mark it).
  226.      *
  227.      * @use \Sq\Service\Plan\MemberPlanLimits::getPlanLimitTimeslots() instead (to include addons).
  228.      */
  229.     public function getLimitTimeslots()
  230.     {
  231.         return $this->limitTimeslots;
  232.     }
  233.     /**
  234.      * @deprecated - (Not really deprecated, but to mark it).
  235.      *
  236.      * @use \Sq\Service\Plan\MemberPlanLimits::getPlanLimitCategories() instead (to include addons).
  237.      */
  238.     public function getLimitCategories()
  239.     {
  240.         return $this->limitCategories;
  241.     }
  242.     /**
  243.      * @deprecated - (Not really deprecated, but to mark it).
  244.      *
  245.      * @use \Sq\Service\Plan\MemberPlanLimits::getPlanLimitImporter() instead (to include addons).
  246.      */
  247.     public function getLimitImporter()
  248.     {
  249.         return $this->limitImporter;
  250.     }
  251.     /**
  252.      * @deprecated - (Not really deprecated, but to mark it).
  253.      *
  254.      * @use \Sq\Service\Plan\MemberPlanLimits::getPlanLimitAutoRss() instead (to include addons).
  255.      */
  256.     public function getLimitAutoRss()
  257.     {
  258.         return $this->limitAutoRss;
  259.     }
  260.     /**
  261.      * @deprecated - (Not really deprecated, but to mark it).
  262.      *
  263.      * @use \Sq\Service\Plan\MemberPlanLimits::getPlanLimitAnalytics() instead (to include addons).
  264.      */
  265.     public function getLimitAnalytics()
  266.     {
  267.         return $this->limitAnalytics;
  268.     }
  269.     /**
  270.      * @deprecated - (Not really deprecated, but to mark it).
  271.      *
  272.      * @use \Sq\Service\Plan\MemberPlanLimits::getPlanLimitAiText() instead (to include addons).
  273.      * @use \Sq\Service\Plan\MemberPlanLimits::canGenerateAiText() instead (to include addons).
  274.      */
  275.     public function getLimitAiText()
  276.     {
  277.         return $this->limitAiText;
  278.     }
  279.     /**
  280.      * @deprecated - (Not really deprecated, but to mark it).
  281.      *
  282.      * @use \Sq\Service\Plan\MemberPlanLimits::getPlanLimitWeeklyTweetCap() instead (to include addons).
  283.      */
  284.     public function getLimitWeeklyTweetCap()
  285.     {
  286.         return $this->limitWeeklyTweetCap;
  287.     }
  288.     /**
  289.      * Get the plan group for this plan.
  290.      * Since each plan has exactly one plan group, this returns the first (and only) element.
  291.      *
  292.      * Will return null for trial plan (no attached group).
  293.      */
  294.     public function getPlanGroup(): ?PlanGroup
  295.     {
  296.         return $this->planGroups->first() ?: null;
  297.     }
  298. }