<commit_before><?php

namespace Service;

use \FPDF;

class PDF extends FPDF
{
    var $widths;
    var $aligns;
    // Background Fill Color
    var $backgrounds;
    // Border
    var $borders;
    var $fontz;

    function SetWidths($w)
    {
        //Set the array of column widths
        $this->widths=$w;
    }

    function SetAligns($a)
    {
        //Set the array of column alignments
        $this->aligns=$a;
    }

    function SetBackgrounds($bfc)
    {
        //Set the array of column alignments
        $this->backgrounds=$bfc;
    }

     /**
     * Array para aplicar borda de cada célula da função Row.
     *
     * O símbolo '&|' significa que pode ser 'E ou OU'
     *
     * @todo add an array parameter to border.
     *
     * @param mixed[] $border int ou string (0 || 1, 'B &| L &| R &| T')
     *
     * @example SetBorder([0, 1, 'TB', 'RL' , 'TBRL'])
     *
     * @return array de string ou de int.
     */
    public function SetBorders($b)
    {
        //Set the array of borders
        $this->borders = $b;
    }

    function SetFontConfig($f){
        // Set the array of column fonts
        $this->fontz = $f;
    }

    function Row($data)
    {

        //Calculate the height of the row
        $nb=0;
        for($i=0;$i<count($data);$i++){
            // Seta a configuração de um array de fontes
            if (is_array($this->fontz[$i]))
                $this->SetFont($this->fontz[$i]['font'], $this->fontz[$i]['style'], $this->fontz[$i]['size']);
            $nb=max($nb,$this->NbLines($this->widths[$i],$data[$i])); // retorna o maior número de linhas
        }

        $h=5*$nb;
        //Concatenate with blank for background fill
        for($i=0;$i<count($data);$i++)
        {
            $diff = $nb-$this->NbLines($this->widths[$i],$data[$i]); // diferença entre a maior linha e a linha atual
            if ($diff > 0)
            {
                for($j=0;$j<($diff);$j++)
                    $data[$i].="\n ";
            }
        }
        //Issue a page break first if needed
        $this->CheckPageBreak($h);
        //Draw the cells of the row
        for($i=0;$i<count($data);$i++)
        {
            $w=$this->widths[$i];
            $a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
            // Array Background Fill Color
            if (!is_array($this->backgrounds)){
                $bfc= $this->backgrounds == true ? true : false;
            } else {
                $bfc=isset($this->backgrounds[$i]) ? $this->backgrounds[$i] : false;
            }
            //Save the current position
            $x=$this->GetX();
            $y=$this->GetY();
            //Draw the border
            if (!isset($this->borders[$i])) {
                $this->Rect($x, $y, $w, $h);
            }
            // Array para setar bordas independentes
            if (!is_array($this->borders)) {
                $b = $this->borders == 1 ? 1 : 0;
            } else {
                $b = isset($this->borders[$i]) ? $this->borders[$i] : 0;
            }
            //Seta Fontes, Tamanhos e Formatos independentes
             if (is_array($this->fontz[$i]))
                $this->SetFont($this->fontz[$i]['font'], $this->fontz[$i]['style'], $this->fontz[$i]['size']);
            //Print the text
            $this->MultiCell($w,5,$data[$i],$b,$a, $bfc);
            //Put the position to the right of the cell
            $this->SetXY($x+$w,$y);
        }
        //Go to the next line
        $this->Ln($h);
    }

    function CheckPageBreak($h)
    {
        //If the height h would cause an overflow, add a new page immediately
        if($this->GetY()+$h>$this->PageBreakTrigger)
            $this->AddPage($this->CurOrientation);
    }

    function NbLines($w,$txt)
    {
        //Computes the number of lines a MultiCell of width w will take
        $cw=&$this->CurrentFont['cw'];
        if($w==0)
            $w=$this->w-$this->rMargin-$this->x;<commit_msg>adicionado utf8 decode no Row PDF<commit_after><?php

namespace Service;

use \FPDF;

class PDF extends FPDF
{
    var $widths;
    var $aligns;
    // Background Fill Color
    var $backgrounds;
    // Border
    var $borders;
    var $fontz;

    function SetWidths($w)
    {
        //Set the array of column widths
        $this->widths=$w;
    }

    function SetAligns($a)
    {
        //Set the array of column alignments
        $this->aligns=$a;
    }

    function SetBackgrounds($bfc)
    {
        //Set the array of column alignments
        $this->backgrounds=$bfc;
    }

     /**
     * Array para aplicar borda de cada célula da função Row.
     *
     * O símbolo '&|' significa que pode ser 'E ou OU'
     *
     * @todo add an array parameter to border.
     *
     * @param mixed[] $border int ou string (0 || 1, 'B &| L &| R &| T')
     *
     * @example SetBorder([0, 1, 'TB', 'RL' , 'TBRL'])
     *
     * @return array de string ou de int.
     */
    public function SetBorders($b)
    {
        //Set the array of borders
        $this->borders = $b;
    }

    function SetFontConfig($f){
        // Set the array of column fonts
        $this->fontz = $f;
    }

    function Row($data)
    {

        //Calculate the height of the row
        $nb=0;
        for($i=0;$i<count($data);$i++){
            // Seta a configuração de um array de fontes
            if (is_array($this->fontz[$i]))
                $this->SetFont($this->fontz[$i]['font'], $this->fontz[$i]['style'], $this->fontz[$i]['size']);
            $nb=max($nb,$this->NbLines($this->widths[$i],$data[$i])); // retorna o maior número de linhas
        }

        $h=5*$nb;
        //Concatenate with blank for background fill
        for($i=0;$i<count($data);$i++)
        {
            $diff = $nb-$this->NbLines($this->widths[$i],$data[$i]); // diferença entre a maior linha e a linha atual
            if ($diff > 0)
            {
                for($j=0;$j<($diff);$j++)
                    $data[$i].="\n ";
            }
        }
        //Issue a page break first if needed
        $this->CheckPageBreak($h);
        //Draw the cells of the row
        for($i=0;$i<count($data);$i++)
        {
            $w=$this->widths[$i];
            $a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
            // Array Background Fill Color
            if (!is_array($this->backgrounds)){
                $bfc= $this->backgrounds == true ? true : false;
            } else {
                $bfc=isset($this->backgrounds[$i]) ? $this->backgrounds[$i] : false;
            }
            //Save the current position
            $x=$this->GetX();
            $y=$this->GetY();
            //Draw the border
            if (!isset($this->borders[$i])) {
                $this->Rect($x, $y, $w, $h);
            }
            // Array para setar bordas independentes
            if (!is_array($this->borders)) {
                $b = $this->borders == 1 ? 1 : 0;
            } else {
                $b = isset($this->borders[$i]) ? $this->borders[$i] : 0;
            }
            //Seta Fontes, Tamanhos e Formatos independentes
             if (is_array($this->fontz[$i]))
                $this->SetFont($this->fontz[$i]['font'], $this->fontz[$i]['style'], $this->fontz[$i]['size']);
            //Print the text
            $this->MultiCell($w,5,utf8_decode($data[$i]),$b,$a, $bfc);
            //Put the position to the right of the cell
            $this->SetXY($x+$w,$y);
        }
        //Go to the next line
        $this->Ln($h);
    }

    function CheckPageBreak($h)
    {
        //If the height h would cause an overflow, add a new page immediately
        if($this->GetY()+$h>$this->PageBreakTrigger)
            $this->AddPage($this->CurOrientation);
    }

    function NbLines($w,$txt)
    {
        //Computes the number of lines a MultiCell of width w will take
        $cw=&$this->CurrentFont['cw'];
        if($w==0)
            $w=$this->w-$this->rMargin-$this->x;
{'fraction_non_alphanumeric': 0.1703414388307925, 'fraction_numerical': 0.004535718785435303, 'mean_word_length': 1.7147742818057456, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 99, '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': '1833254', 'n_tokens_mistral': 2608, 'n_tokens_neox': 2534, 'n_words': 618}