src/Entity/ChannelSetting.php line 26

Open in your IDE?
  1. <?php
  2. /**
  3.  * @license SILK SOFTWARE HOUSE SP Z O O
  4.  */
  5. namespace App\Entity;
  6. use App\Entity\Traits\IdTrait;
  7. use App\Entity\Traits\TimePreUpdateTrait;
  8. use App\Entity\Traits\TimeTrait;
  9. use App\Model\DefaultStrengthPoints;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use DateTime;
  13. use Symfony\Component\Validator\Constraints as Assert;
  14. use App\Validator\Constraints as AppAssert;
  15. /**
  16.  * Class ChannelSetting.
  17.  * Simple channel consists of measurement channel. Calculated channel consist of sum of children channel settings.
  18.  *
  19.  * @ORM\Table("channel_settings")
  20.  * @ORM\Entity(repositoryClass="App\Repository\ChannelSettingRepository")
  21.  * @ORM\HasLifecycleCallbacks()
  22.  */
  23. class ChannelSetting
  24. {
  25.     use IdTrait;
  26.     use TimeTrait;
  27.     use TimePreUpdateTrait;
  28.     /**
  29.      * Measurement setting.
  30.      *
  31.      * @var MeasurementSetting|null
  32.      *
  33.      * @ORM\ManyToOne(targetEntity="App\Entity\MeasurementSetting", inversedBy="channelSettings")
  34.      * @ORM\JoinColumn(name="measurement_setting_id", nullable=true)
  35.      */
  36.     private $measurementSetting;
  37.     /**
  38.      * Channel has to be set for simple channel display - it can be empty when this channel is calculated from different ones.
  39.      *
  40.      * @var Channel|null
  41.      *
  42.      * @ORM\ManyToOne(targetEntity="App\Entity\Channel", inversedBy="channelSettings")
  43.      * @ORM\JoinColumn(name="channel_id", nullable=true)
  44.      */
  45.     private $channel;
  46.     /**
  47.      * Priority.
  48.      *
  49.      * @var int|null
  50.      *
  51.      * @ORM\Column(name="priority", type="integer", nullable=true, options={"comment": "Channel priority."})
  52.      */
  53.     private $priority;
  54.     /**
  55.      * Channel name.
  56.      *
  57.      * @Assert\Length(max=255)
  58.      *
  59.      * @var string|null
  60.      *
  61.      * @ORM\Column(name="name", type="string", length=255, nullable=true, options={"comment": "Channel name."})
  62.      */
  63.     private $name;
  64.     /**
  65.      * @var int|null
  66.      *
  67.      * @ORM\Column(name="number", type="integer", nullable=true, options={"comment": "Channel number."})
  68.      */
  69.     private $number;
  70.     /**
  71.      * Recipe.
  72.      *
  73.      * @var Recipe|null
  74.      *
  75.      * @ORM\ManyToOne(targetEntity="App\Entity\Recipe")
  76.      * @ORM\JoinColumn(name="recipe_id", nullable=true)
  77.      */
  78.     private $recipe;
  79.     /**
  80.      * When set it means that this channel will be calculated from few others.
  81.      * Watch out for circular reference!!!
  82.      *
  83.      * @var ChannelSettingCoefficient[]|ArrayCollection
  84.      *
  85.      * @ORM\OneToMany(targetEntity="App\Entity\ChannelSettingCoefficient", cascade={"persist", "remove"}, mappedBy="parentSetting", orphanRemoval=true)
  86.      *
  87.      * @Assert\Valid()
  88.      *
  89.      * @AppAssert\NotCircular()
  90.      */
  91.     private $channelSettingCoefficients;
  92.     /**
  93.      * Is average weighted.
  94.      *
  95.      * @var bool
  96.      *
  97.      * @ORM\Column(name="is_average_weighted", type="boolean", nullable=false, options={"default": false, "comment": "Is average weighted."})
  98.      */
  99.     private $isAverageWeighted false;
  100.     /**
  101.      * Mixing time point.
  102.      *
  103.      * @var DateTime|null
  104.      *
  105.      * @Assert\LessThan(
  106.      *     message="This value should be less than measurement starting time {{ compared_value }}.",
  107.      *     propertyPath="measurementStartedAt"
  108.      * )
  109.      *
  110.      * @ORM\Column(name="mixing_time_point", type="datetime", nullable=true, options={"comment": "Mixing time point."})
  111.      */
  112.     private $mixingTimePoint;
  113.     /**
  114.      * Mixing temperature.
  115.      *
  116.      * @var float|null
  117.      *
  118.      * @Assert\Range(min="-273.15", max="1416833")
  119.      *
  120.      * @ORM\Column(name="mixing_temperature", type="float", nullable=true, options={"comment": "Mixing temperature"})
  121.      */
  122.     private $mixingTemperature;
  123.     /**
  124.      * Casting time point.
  125.      *
  126.      * @var DateTime|null
  127.      *
  128.      * @ORM\Column(name="casting_time_point", type="datetime", nullable=true, options={"comment": "Casting time point."})
  129.      */
  130.     private $castingTimePoint;
  131.     /**
  132.      * Starting time point.
  133.      *
  134.      * @var DateTime|null
  135.      *
  136.      * @ORM\Column(name="starting_time_point", type="datetime", nullable=true, options={"comment": "Starting time point."})
  137.      */
  138.     private $startingTimePoint;
  139.     /**
  140.      * Array of strings (times in YmdHis format).
  141.      *
  142.      * @var string[]
  143.      *
  144.      * @ORM\Column(name="hidden_probes", type="json", nullable=true, options={"default": "{}", "comment": "Hidden probes."})
  145.      */
  146.     private $hiddenProbes = [];
  147.     /**
  148.      * Strength points.
  149.      *
  150.      * @var array
  151.      *
  152.      * @ORM\Column(name="strength_points", type="json", nullable=false, options={"comment": "Strength points.", "default": "{}"})
  153.      */
  154.     private $strengthPoints = [];
  155.     /**
  156.      * @var bool
  157.      *
  158.      * @ORM\Column(name="skip_recipe", type="boolean", nullable=false, options={"comment": "Is channel skiping recipe or standard recipe"})
  159.      */
  160.     private $skipRecipe false;
  161.     /**
  162.      * @var bool
  163.      *
  164.      * @ORM\Column(name="is_added_by_user", type="boolean", nullable=false, options={"comment": "Is added by user"})
  165.      */
  166.     private $isAddedByUser false;
  167.     /**
  168.      * @var bool
  169.      *
  170.      * @ORM\Column(name="is_deleted", type="boolean", nullable=false, options={"comment": "Is channel deleted"})
  171.      */
  172.     private $isDeleted false;
  173.     /**
  174.      * @var int
  175.      *
  176.      * @ORM\Column(name="diagram_group", type="integer", nullable=false, options={"comment": "Temperature diagram group.", "default": 1})
  177.      */
  178.     private $diagramGroup 1;
  179.     /**
  180.      * ChannelSetting constructor.
  181.      */
  182.     public function __construct()
  183.     {
  184.         $this->channelSettingCoefficients = new ArrayCollection();
  185.         $this->strengthPoints DefaultStrengthPoints::get();
  186.     }
  187.     /**
  188.      * ChannelSetting clone
  189.      */
  190.     public function __clone()
  191.     {
  192.         $this->id null;
  193.     }
  194.     /**
  195.      * Get measurement setting.
  196.      *
  197.      * @return MeasurementSetting|null
  198.      */
  199.     public function getMeasurementSetting(): ?MeasurementSetting
  200.     {
  201.         return $this->measurementSetting;
  202.     }
  203.     /**
  204.      * Set measurement setting.
  205.      *
  206.      * @param MeasurementSetting|null $measurementSetting
  207.      *
  208.      * @return ChannelSetting
  209.      */
  210.     public function setMeasurementSetting(?MeasurementSetting $measurementSetting): ChannelSetting
  211.     {
  212.         $this->measurementSetting $measurementSetting;
  213.         return $this;
  214.     }
  215.     /**
  216.      * Get channel setting.
  217.      *
  218.      * @return Channel|null
  219.      */
  220.     public function getChannel(): ?Channel
  221.     {
  222.         return $this->channel;
  223.     }
  224.     /**
  225.      * Channel setting.
  226.      *
  227.      * @param Channel|null $channel
  228.      *
  229.      * @return ChannelSetting
  230.      */
  231.     public function setChannel($channel): ChannelSetting
  232.     {
  233.         $this->channel $channel;
  234.         return $this;
  235.     }
  236.     /**
  237.      * Get priority.
  238.      *
  239.      * @return int|null
  240.      */
  241.     public function getPriority(): ?int
  242.     {
  243.         return $this->priority;
  244.     }
  245.     /**
  246.      * Set priority.
  247.      *
  248.      * @param int|null $priority
  249.      *
  250.      * @return ChannelSetting
  251.      */
  252.     public function setPriority(?int $priority): ChannelSetting
  253.     {
  254.         $this->priority $priority;
  255.         return $this;
  256.     }
  257.     /**
  258.      * Get channel name.
  259.      *
  260.      * @return string|null
  261.      */
  262.     public function getName(): ?string
  263.     {
  264.         return $this->name;
  265.     }
  266.     /**
  267.      * Set channel name.
  268.      *
  269.      * @param string|null $name
  270.      *
  271.      * @return ChannelSetting
  272.      */
  273.     public function setName(?string $name): ChannelSetting
  274.     {
  275.         $this->name $name;
  276.         return $this;
  277.     }
  278.     /**
  279.      * Get recipe.
  280.      *
  281.      * @return Recipe|null
  282.      */
  283.     public function getRecipe(): ?Recipe
  284.     {
  285.         return $this->recipe;
  286.     }
  287.     /**
  288.      * Set recipe.
  289.      *
  290.      * @param Recipe|null $recipe
  291.      *
  292.      * @return ChannelSetting
  293.      */
  294.     public function setRecipe(?Recipe $recipe): ChannelSetting
  295.     {
  296.         $this->recipe $recipe;
  297.         return $this;
  298.     }
  299.     /**
  300.      * Get is average weighted.
  301.      *
  302.      * @return bool
  303.      */
  304.     public function getIsAverageWeighted(): bool
  305.     {
  306.         return $this->isAverageWeighted;
  307.     }
  308.     /**
  309.      * Set is average weighted.
  310.      *
  311.      * @param bool $isAverageWeighted
  312.      *
  313.      * @return ChannelSetting
  314.      */
  315.     public function setIsAverageWeighted(bool $isAverageWeighted): ChannelSetting
  316.     {
  317.         $this->isAverageWeighted $isAverageWeighted;
  318.         return $this;
  319.     }
  320.     /**
  321.      * Get number.
  322.      * Note: please don't add static values here ie. '?? 1'; it will break channelViewFactory.
  323.      *
  324.      * @return int|null
  325.      */
  326.     public function getNumber(): ?int
  327.     {
  328.         return $this->number;
  329.     }
  330.     /**
  331.      * Set number.
  332.      *
  333.      * @param int|null $number
  334.      *
  335.      * @return ChannelSetting
  336.      */
  337.     public function setNumber(?int $number): ChannelSetting
  338.     {
  339.         $this->number $number;
  340.         return $this;
  341.     }
  342.     /**
  343.      * Get type.
  344.      *
  345.      * @return string
  346.      */
  347.     public function getType(): string
  348.     {
  349.         return $this->channelSettingCoefficients->count() ? 'calculated' 'default';
  350.     }
  351.     /**
  352.      * Set type. Todo: it does nothing.
  353.      *
  354.      * @param string $type
  355.      *
  356.      * @return ChannelSetting
  357.      */
  358.     public function setType(string $type): ChannelSetting
  359.     {
  360.         return $this;
  361.     }
  362.     /**
  363.      * Get mixing time point.
  364.      *
  365.      * @return DateTime|null
  366.      */
  367.     public function getMixingTimePoint(): ?DateTime
  368.     {
  369.         return $this->mixingTimePoint;
  370.     }
  371.     /**
  372.      * Set mixing time point.
  373.      *
  374.      * @param DateTime|null $mixingTimePoint
  375.      *
  376.      * @return ChannelSetting
  377.      */
  378.     public function setMixingTimePoint(?DateTime $mixingTimePoint): ChannelSetting
  379.     {
  380.         $this->mixingTimePoint $mixingTimePoint;
  381.         return $this;
  382.     }
  383.     /**
  384.      * Set mixing temperature.
  385.      *
  386.      * @param float|null $mixingTemperature
  387.      *
  388.      * @return ChannelSetting
  389.      */
  390.     public function setMixingTemperature(?float $mixingTemperature): ChannelSetting
  391.     {
  392.         $this->mixingTemperature $mixingTemperature;
  393.         return $this;
  394.     }
  395.     /**
  396.      * Get mixing temperature.
  397.      *
  398.      * @return float|null
  399.      */
  400.     public function getMixingTemperature(): ?float
  401.     {
  402.         return $this->mixingTemperature;
  403.     }
  404.     /**
  405.      * Get casting time point.
  406.      *
  407.      * @return DateTime|null
  408.      */
  409.     public function getCastingTimePoint(): ?DateTime
  410.     {
  411.         return $this->castingTimePoint;
  412.     }
  413.     /**
  414.      * Set casting time point.
  415.      *
  416.      * @param DateTime|null $castingTimePoint
  417.      *
  418.      * @return ChannelSetting
  419.      */
  420.     public function setCastingTimePoint(?DateTime $castingTimePoint): ChannelSetting
  421.     {
  422.         $this->castingTimePoint $castingTimePoint;
  423.         return $this;
  424.     }
  425.     /**
  426.      * Get starting time point.
  427.      *
  428.      * @return DateTime|null
  429.      */
  430.     public function getStartingTimePoint(): ?DateTime
  431.     {
  432.         return $this->startingTimePoint;
  433.     }
  434.     /**
  435.      * Set starting time point.
  436.      *
  437.      * @param DateTime|null $startingTimePoint
  438.      *
  439.      * @return ChannelSetting
  440.      */
  441.     public function setStartingTimePoint(?DateTime $startingTimePoint): ChannelSetting
  442.     {
  443.         $this->startingTimePoint $startingTimePoint;
  444.         return $this;
  445.     }
  446.     /**
  447.      * @return ChannelSettingCoefficient[]|ArrayCollection
  448.      */
  449.     public function getChannelSettingCoefficients()
  450.     {
  451.         return $this->channelSettingCoefficients;
  452.     }
  453.     /**
  454.      * Add channel setting coefficient.
  455.      *
  456.      * @param ChannelSettingCoefficient $channelSettingCoefficient
  457.      *
  458.      * @return ChannelSetting
  459.      */
  460.     public function addChannelSettingCoefficient(ChannelSettingCoefficient $channelSettingCoefficient): ChannelSetting
  461.     {
  462.         if (!$this->channelSettingCoefficients->contains($channelSettingCoefficient)) {
  463.             $this->channelSettingCoefficients->add($channelSettingCoefficient->setParentSetting($this));
  464.         }
  465.         return $this;
  466.     }
  467.     /**
  468.      * Remove channel setting coefficient.
  469.      *
  470.      * @param ChannelSettingCoefficient $channelSettingCoefficient
  471.      *
  472.      * @return ChannelSetting
  473.      */
  474.     public function removeChannelSettingCoefficient(ChannelSettingCoefficient $channelSettingCoefficient): ChannelSetting
  475.     {
  476.         if ($this->channelSettingCoefficients->contains($channelSettingCoefficient)) {
  477.             $this->channelSettingCoefficients->removeElement($channelSettingCoefficient);
  478.         }
  479.         return $this;
  480.     }
  481.     /**
  482.      * To string.
  483.      *
  484.      * @return string|null
  485.      */
  486.     public function __toString(): string
  487.     {
  488.         if (!$this->channel || null === $this->channel->getMeasurement() || null === $this->getChannel()) {
  489.             return $this->getFullName(falsefalse);
  490.         }
  491.         return $this->getFullName() ?? '';
  492.     }
  493.     /**
  494.      * Get full name.
  495.      *
  496.      * @param bool $withMeasurement
  497.      * @param bool $withTraceability
  498.      *
  499.      * @return string
  500.      */
  501.     public function getFullName(bool $withMeasurement truebool $withTraceability false): string
  502.     {
  503.         $traceability $withTraceability $this->getTraceabilityName() : '';
  504.         $defaultMeasurement null;
  505.         if (!$withTraceability && $withMeasurement) {
  506.             $defaultMeasurement $this->measurementSetting->getMeasurement();
  507.         }
  508.         $name $this->getName();
  509.         if (!$name) {
  510.             if ('default' !== $this->getType()) {
  511.                 $name '{{calculated-channel}}';
  512.             } elseif ($this->isAddedByUser()) {
  513.                 $name '{{added-channel}}';
  514.                 if ($withMeasurement) {
  515.                     $name .= ': '.$this->channel->getMeasurement()->getNameWithFallback()
  516.                         .' ({{Sequence}} '.($this->getChannel()->getNumber()).')';
  517.                 }
  518.                 return $name;
  519.                 //return '{{added-channel}}: '.$this->channel->getMeasurement()->getName(true).' ({{Sequence}} '.($this->getChannel()->getNumber()+1).')';
  520.             } else {
  521.                 $name '{{Channel}} '.$this->getNumber();
  522.             }
  523.         }
  524.         $name = ('default' !== $this->getType() && true === $withTraceability) ? '' $name;
  525.         $measurement = ($withMeasurement && $this->channel) ? $this->channel->getMeasurement() : $defaultMeasurement;
  526.         if ($measurement) {
  527.             $name .= ' '.$measurement->getName() ?? '{{Measurement}} '.$this->getId();
  528.         }
  529.         return ($this->name ?? $name).$traceability;
  530.     }
  531.     /**
  532.      * Is duplicate.
  533.      *
  534.      * @Assert\IsFalse(message="This channel already exists.")
  535.      *
  536.      * @return bool
  537.      */
  538.     public function isDuplicate()
  539.     {
  540.         if (!$this->channel) {
  541.             return false;
  542.         }
  543.         foreach ($this->measurementSetting->getChannelSettings() as $channelSetting) {
  544.             if ($channelSetting->getId() !== $this->id && $channelSetting->getChannel()
  545.                 && $channelSetting->getChannel()->getId() === $this->channel->getId()
  546.                 && $channelSetting->getRecipe() == $this->getRecipe()) {
  547.                 return true;
  548.             }
  549.         }
  550.         return false;
  551.     }
  552.     /**
  553.      * @Assert\IsTrue(message="Please select channel.")
  554.      *
  555.      * @return bool
  556.      */
  557.     public function hasChannelSettingCoefficients(): bool
  558.     {
  559.         return $this->channel || $this->channelSettingCoefficients->count() > 0;
  560.     }
  561.     /**
  562.      * Get measurement started at.
  563.      *
  564.      * @return DateTime
  565.      */
  566.     public function getMeasurementStartedAt(): ?DateTime
  567.     {
  568.         return $this->getMeasurement() ? $this->getMeasurement()->getStartedAt() : null;
  569.     }
  570.     /**
  571.      * Get measurement.
  572.      *
  573.      * @return Measurement|null
  574.      */
  575.     public function getMeasurement(): ?Measurement
  576.     {
  577.         return $this->channel $this->channel->getMeasurement()
  578.             : ($this->getMeasurementSetting() ? $this->getMeasurementSetting()->getMeasurement() : null);
  579.     }
  580.     /**
  581.      * Get is stopped.
  582.      *
  583.      * @param int|null $depth
  584.      *
  585.      * @return bool
  586.      */
  587.     public function getIsStopped($depth 0): bool
  588.     {
  589.         if (++$depth 5) {
  590.             return false;
  591.         }
  592.         if ($this->channel && $this->channel->getMeasurement() && $this->channel->getMeasurement()->getIsFinished()) {
  593.             return true;
  594.         }
  595.         $isStopped false;
  596.         foreach ($this->channelSettingCoefficients as $relation) {
  597.             if (!$relation->getChildrenSetting()->getIsStopped($depth)) {
  598.                 return false;
  599.             }
  600.             $isStopped true;
  601.         }
  602.         return $isStopped;
  603.     }
  604.     /**
  605.      * Hide probe.
  606.      *
  607.      * @param DateTime $probeTime
  608.      *
  609.      * @return ChannelSetting
  610.      */
  611.     public function hideProbe(DateTime $probeTime)
  612.     {
  613.         if (!in_array($probeTime->format('YmdHis'), $this->hiddenProbes)) {
  614.             $this->hiddenProbes[] = $probeTime->format('YmdHis');
  615.         }
  616.         return $this;
  617.     }
  618.     /**
  619.      * Show probe.
  620.      *
  621.      * @param DateTime $probeTime
  622.      *
  623.      * @return ChannelSetting
  624.      */
  625.     public function showProbe(DateTime $probeTime): ChannelSetting
  626.     {
  627.         if (false !== ($key array_search($probeTime->format('YmdHis'), $this->hiddenProbes))) {
  628.             unset($this->hiddenProbes[$key]);
  629.         }
  630.         return $this;
  631.     }
  632.     /**
  633.      * Get is probe hidden.
  634.      *
  635.      * @param DateTime $probeTime
  636.      *
  637.      * @return bool
  638.      */
  639.     public function getIsProbeHidden(DateTime $probeTime): bool
  640.     {
  641.         return in_array($probeTime->format('YmdHis'), $this->hiddenProbes);
  642.     }
  643.     /**
  644.      * @return $this
  645.      */
  646.     public function clearHiddenProbes()
  647.     {
  648.         $this->hiddenProbes = [];
  649.         return $this;
  650.     }
  651.     /**
  652.      * Get channel short name.
  653.      *
  654.      * @return string
  655.      */
  656.     public function getChannelShortName(): string
  657.     {
  658.         return $this->getFullName(false);
  659.     }
  660.     /**
  661.      * Get traceability name.
  662.      *
  663.      * @return string
  664.      */
  665.     public function getTraceabilityName()
  666.     {
  667.         if (!$this->channel || !$this->channel->getId()) {
  668.             $name null;
  669.             $sequencesArray = [];
  670.             foreach ($this->channelSettingCoefficients as $coefficient) {
  671.                 $name $coefficient->getChildrenSetting()->getMeasurement()->getNameWithFallback();
  672.                 $sequencesArray[] = $name.' ('.$coefficient->getCoefficient().' * '.$coefficient->getName().')';
  673.             }
  674.             $sequence implode(' + '$sequencesArray);
  675.             return '{{Calculated from}}: '.($this->isAverageWeighted
  676.                     '('.$sequence.') / '.$this->channelSettingCoefficients->count() : $sequence);
  677.         }
  678.         $device $this->getMeasurement()->getDevice();
  679.         $deviceId $device->getSerialNumber();
  680.         $calibratedAt $device->getCalibratedAt() ? $device->getCalibratedAt()->format('Y-m-d') : '-';
  681.         return ' {{Device}} '.$deviceId.', '
  682.             .'{{Sequence}}'.' '.($this->channel->getNumber()).', {{Calibrated at}}: '.$calibratedAt;
  683.     }
  684.     /**
  685.      * Get traceability tree.
  686.      *
  687.      * @return array
  688.      */
  689.     public function getTraceabilityTree()
  690.     {
  691.         $nodes $this->getTraceabilityNodes();
  692.         $name = (!$this->getNumber() && $this->channel)
  693.             ? $this->channel->getSequenceName()
  694.             : (($this->channel) ? $this->channel->getSequenceName() : (string) $this);
  695.         /* Traceability channel name changed: task #261 */
  696.         $name str_replace('Sequence''traceability_channel'$name);
  697.         $nodes = [
  698.                 'text' => str_replace(
  699.                     ['{{''}}'],
  700.                     '--',
  701.                     "<strong>".(strlen($name) > 105 substr($name0105)."..." $name).",
  702.                     </strong>".$this->getTraceabilityName()
  703.                 ),
  704.             ] + (count($nodes) ? ['nodes' => $nodes] : []);
  705.         return $nodes;
  706.     }
  707.     /**
  708.      * Get traceability nodes.
  709.      *
  710.      * @return array
  711.      */
  712.     public function getTraceabilityNodes()
  713.     {
  714.         $nodes = [];
  715.         foreach ($this->channelSettingCoefficients as $coefficient) {
  716.             $nodes[] = $coefficient->getChildrenSetting()->getTraceabilityTree();
  717.         }
  718.         return $nodes;
  719.     }
  720.     /**
  721.      * Get strength points.
  722.      *
  723.      * @return array
  724.      */
  725.     public function getStrengthPoints(): array
  726.     {
  727.         return $this->strengthPoints;
  728.     }
  729.     /**
  730.      * Set strength points.
  731.      *
  732.      * @param array $strengthPoints
  733.      *
  734.      * @return ChannelSetting
  735.      */
  736.     public function setStrengthPoints(array $strengthPoints): ChannelSetting
  737.     {
  738.         $this->strengthPoints $strengthPoints;
  739.         return $this;
  740.     }
  741.     /**
  742.      * Get active strength points.
  743.      *
  744.      * @return array
  745.      */
  746.     public function getActiveStrengthPoints()
  747.     {
  748.         return array_keys(array_filter($this->strengthPoints, function ($element) {
  749.             return true === $element;
  750.         }));
  751.     }
  752.     /**
  753.      * @return bool
  754.      */
  755.     public function isDeleted(): bool
  756.     {
  757.         return $this->isDeleted;
  758.     }
  759.     /**
  760.      * @param bool $isDeleted
  761.      *
  762.      * @return self
  763.      */
  764.     public function setIsDeleted(bool $isDeleted): ChannelSetting
  765.     {
  766.         $this->isDeleted $isDeleted;
  767.         return $this;
  768.     }
  769.     /**
  770.      * @return bool
  771.      */
  772.     public function isAddedByUser(): bool
  773.     {
  774.         return $this->isAddedByUser;
  775.     }
  776.     /**
  777.      * @param bool $isAddedByUser
  778.      *
  779.      * @return self
  780.      */
  781.     public function setIsAddedByUser(bool $isAddedByUser): ChannelSetting
  782.     {
  783.         $this->isAddedByUser $isAddedByUser;
  784.         return $this;
  785.     }
  786.     public function getDiagramGroup(): int
  787.     {
  788.         return $this->diagramGroup ?: 1;
  789.     }
  790.     public function setDiagramGroup(int $diagramGroup): ChannelSetting
  791.     {
  792.         $this->diagramGroup max(1min(2$diagramGroup));
  793.         return $this;
  794.     }
  795.     /**
  796.      * @return bool
  797.      */
  798.     public function isSkipRecipe(): bool
  799.     {
  800.         return $this->skipRecipe;
  801.     }
  802.     /**
  803.      * @param bool $skipRecipe
  804.      *
  805.      * @return self
  806.      */
  807.     public function setIsSkipRecipe(bool $skipRecipe): ChannelSetting
  808.     {
  809.         $this->skipRecipe $skipRecipe;
  810.         return $this;
  811.     }
  812. }