<commit_before><?php

namespace AppBundle\Service;

use AppBundle\Entity\Blade;
use AppBundle\Entity\BladeDamage;
use AppBundle\Enum\BladeDamageEdgeEnum;
use AppBundle\Enum\BladeDamagePositionEnum;
use AppBundle\Pdf\CustomTcpdf;

/**
 * Class AuditModelDiagramBridgeService
 *
 * @category Service
 * @package  AppBundle\Service
 * @author   <NAME> <<EMAIL>>
 */
class AuditModelDiagramBridgeService
{
    const PDF_TOTAL_WIDHT      = 210;
    const DIAGRAM_HEIGHT       = 60;
    const GAP_SQUARE_SIZE      = 5;
    const GAP_SQUARE_HALF_SIZE = 2.5;

    /**
     * @var float
     */
    private $x1;

    /**
     * @var float
     */
    private $x2;

    /**
     * @var float
     */
    private $y1;

    /**
     * @var float
     */
    private $y2;

    /**
     * @var float
     */
    private $xQ1;

    /**
     * @var float
     */
    private $xQ2;

    /**
     * @var float
     */
    private $xQ3;

    /**
     * @var float
     */
    private $xQ4;

    /**
     * @var float
     */
    private $xQ5;

    /**
     * @var float
     */
    private $yQ1;

    /**
     * @var float
     */
    private $yQ2;

    /**
     * @var float
     */
    private $yMiddle;

    /**
     * @var float
     */
    private $yQ3;

    /**
     * @var float
     */
    private $yQ4;

    /**
     * @var float
     */
    private $xScaleGap;

    /**
     * @var float
     */
    private $yScaleGap;

    /**
     * @var
     */
    private $maxFunctionYPoint;

    /**
     * 
     * 
     * Methods
     * 
     * 
     */

    /**
     * AuditModelDiagramBridgeService constructor
     */
    public function __construct()
    {
        $this->x1 = CustomTcpdf::PDF_MARGIN_LEFT;
        $this->x2 = self::PDF_TOTAL_WIDHT - CustomTcpdf::PDF_MARGIN_RIGHT;
        $this->xQ1 = $this->x1 + 0.25;
        $this->xQ5 = $this->x2 - 0.25;
        $this->xScaleGap = $this->xQ5 - $this->xQ1;
        $this->xQ2 = $this->xQ1 + ($this->xScaleGap / 4);
        $this->xQ3 = $this->xQ2 + ($this->xScaleGap / 4);
        $this->xQ4 = $this->xQ3 + ($this->xScaleGap / 4);
    }
    
    /**
     * @param float $y
     *
     * @return $this
     */
    public function setYs($y)
    {
        $this->y1 = $y;
        $this->y2 = $y + self::DIAGRAM_HEIGHT;
        $this->yQ1 = $this->y1  + 5.5;
        $this->yQ2 = $this->yQ1 + 17;
        $this->yQ3 = $this->yQ2 + 16.75;
        $this->yQ4 = $this->yQ3 + 17;
        $this->yMiddle = $this->yQ2 + (($this->yQ3 - $this->yQ2) / 2) + 0.75;
        $this->yScaleGap = $this->yQ2 - $this->yQ1;

        return $this;
    }

    /**
     * Get MaxFunctionYPoint
     *
     * @return mixed
     */
    public function getMaxFunctionYPoint()
    {
        return $this->maxFunctionYPoint;
    }

    /**
     * Set MaxFunctionYPoint
     *
     * @param mixed $maxFunctionYPoint
     *
     * @return $this
     */
    public function setMaxFunctionYPoint($maxFunctionYPoint)
    {
        $this->maxFunctionYPoint = $maxFunctionYPoint;

        return $this;
    }

    /**
     * @param Blade $blade
     *
     * @return float|int
     */
    public function calculateMaxFunctionYPoint(Blade $blade)
    {
        $maxY = 0;
        for ($x = 0; $x <= $blade->getLength(); $x = $x + 0.5) {
            $val = $this->isolatedDeltaY($x);
            if ($maxY < $val) {
                $maxY = $val;
            }
        }
        $this->setMaxFunctionYPoint($maxY);

        return $maxY;
    }

    /**
     * @param BladeDamage $bladeDamage
     *
     * @return float
     */
    public function getGapX(BladeDamage $bladeDamage)
    {
        return $this->xQ1 + (($bladeDamage->getRadius() * $this->xScaleGap) / $bladeDamage->getAuditWindmillBlade()->getWindmillBlade()->getWindmill()->getBladeType()->getLength());
    }

    /**
     * @param BladeDamage $bladeDamage
     *
     * @return float
     */
    public function getGapXSize(BladeDamage $bladeDamage)
    {
        $result = (($bladeDamage->getSize() / 100) * $this->xScaleGap) / $bladeDamage->getAuditWindmillBlade()->getWindmillBlade()->getWindmill()->getBladeType()->getLength();<commit_msg>insight fix: Usage of a function in loops should be avoided<commit_after><?php

namespace AppBundle\Service;

use AppBundle\Entity\Blade;
use AppBundle\Entity\BladeDamage;
use AppBundle\Enum\BladeDamageEdgeEnum;
use AppBundle\Enum\BladeDamagePositionEnum;
use AppBundle\Pdf\CustomTcpdf;

/**
 * Class AuditModelDiagramBridgeService
 *
 * @category Service
 * @package  AppBundle\Service
 * @author   <NAME> <<EMAIL>>
 */
class AuditModelDiagramBridgeService
{
    const PDF_TOTAL_WIDHT      = 210;
    const DIAGRAM_HEIGHT       = 60;
    const GAP_SQUARE_SIZE      = 5;
    const GAP_SQUARE_HALF_SIZE = 2.5;

    /**
     * @var float
     */
    private $x1;

    /**
     * @var float
     */
    private $x2;

    /**
     * @var float
     */
    private $y1;

    /**
     * @var float
     */
    private $y2;

    /**
     * @var float
     */
    private $xQ1;

    /**
     * @var float
     */
    private $xQ2;

    /**
     * @var float
     */
    private $xQ3;

    /**
     * @var float
     */
    private $xQ4;

    /**
     * @var float
     */
    private $xQ5;

    /**
     * @var float
     */
    private $yQ1;

    /**
     * @var float
     */
    private $yQ2;

    /**
     * @var float
     */
    private $yMiddle;

    /**
     * @var float
     */
    private $yQ3;

    /**
     * @var float
     */
    private $yQ4;

    /**
     * @var float
     */
    private $xScaleGap;

    /**
     * @var float
     */
    private $yScaleGap;

    /**
     * @var
     */
    private $maxFunctionYPoint;

    /**
     * 
     * 
     * Methods
     * 
     * 
     */

    /**
     * AuditModelDiagramBridgeService constructor
     */
    public function __construct()
    {
        $this->x1 = CustomTcpdf::PDF_MARGIN_LEFT;
        $this->x2 = self::PDF_TOTAL_WIDHT - CustomTcpdf::PDF_MARGIN_RIGHT;
        $this->xQ1 = $this->x1 + 0.25;
        $this->xQ5 = $this->x2 - 0.25;
        $this->xScaleGap = $this->xQ5 - $this->xQ1;
        $this->xQ2 = $this->xQ1 + ($this->xScaleGap / 4);
        $this->xQ3 = $this->xQ2 + ($this->xScaleGap / 4);
        $this->xQ4 = $this->xQ3 + ($this->xScaleGap / 4);
    }
    
    /**
     * @param float $y
     *
     * @return $this
     */
    public function setYs($y)
    {
        $this->y1 = $y;
        $this->y2 = $y + self::DIAGRAM_HEIGHT;
        $this->yQ1 = $this->y1  + 5.5;
        $this->yQ2 = $this->yQ1 + 17;
        $this->yQ3 = $this->yQ2 + 16.75;
        $this->yQ4 = $this->yQ3 + 17;
        $this->yMiddle = $this->yQ2 + (($this->yQ3 - $this->yQ2) / 2) + 0.75;
        $this->yScaleGap = $this->yQ2 - $this->yQ1;

        return $this;
    }

    /**
     * Get MaxFunctionYPoint
     *
     * @return mixed
     */
    public function getMaxFunctionYPoint()
    {
        return $this->maxFunctionYPoint;
    }

    /**
     * Set MaxFunctionYPoint
     *
     * @param mixed $maxFunctionYPoint
     *
     * @return $this
     */
    public function setMaxFunctionYPoint($maxFunctionYPoint)
    {
        $this->maxFunctionYPoint = $maxFunctionYPoint;

        return $this;
    }

    /**
     * @param Blade $blade
     *
     * @return float|int
     */
    public function calculateMaxFunctionYPoint(Blade $blade)
    {
        $maxY = 0;
        $bladeLength = $blade->getLength();
        for ($x = 0; $x <= $bladeLength; $x = $x + 0.5) {
            $val = $this->isolatedDeltaY($x);
            if ($maxY < $val) {
                $maxY = $val;
            }
        }
        $this->setMaxFunctionYPoint($maxY);

        return $maxY;
    }

    /**
     * @param BladeDamage $bladeDamage
     *
     * @return float
     */
    public function getGapX(BladeDamage $bladeDamage)
    {
        return $this->xQ1 + (($bladeDamage->getRadius() * $this->xScaleGap) / $bladeDamage->getAuditWindmillBlade()->getWindmillBlade()->getWindmill()->getBladeType()->getLength());
    }

    /**
     * @param BladeDamage $bladeDamage
     *
     * @return float
     */
    public function getGapXSize(BladeDamage $bladeDamage)
    {
        $result = (($bladeDamage->getSize() / 100) * $this->xScaleGap) / $bladeDamage->getAuditWindmillBlade()->getWindmillBlade()->getWindmill()->getBladeType()->getLength();
{'fraction_non_alphanumeric': 0.1570964247020585, 'fraction_numerical': 0.01950162513542795, 'mean_word_length': 1.7509933774834436, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 119, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1084024', 'n_tokens_mistral': 3166, 'n_tokens_neox': 3028, 'n_words': 513}