Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php declare(strict_types=1); namespace PhpOffice\PhpSpreadsheetTests\Worksheet; use P..

Decoded Output download

<?php

declare(strict_types=1);

namespace PhpOffice\PhpSpreadsheetTests\Worksheet;

use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Style\Color;
use PhpOffice\PhpSpreadsheet\Style\Conditional;
use PHPUnit\Framework\TestCase;

class ConditionalStyleTest extends TestCase
{
    protected Spreadsheet $spreadsheet;

    protected function setUp(): void
    {
        parent::setUp();

        $this->spreadsheet = new Spreadsheet();

        $conditional1 = new Conditional();
        $conditional1->setConditionType(Conditional::CONDITION_CELLIS);
        $conditional1->setOperatorType(Conditional::OPERATOR_LESSTHAN);
        $conditional1->addCondition('0');
        $conditional1->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_RED);
        $conditional1->getStyle()->getFont()->setBold(true);

        $conditional2 = new Conditional();
        $conditional2->setConditionType(Conditional::CONDITION_CELLIS);
        $conditional2->setOperatorType(Conditional::OPERATOR_EQUAL);
        $conditional2->addCondition('0');
        $conditional2->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_YELLOW);
        $conditional2->getStyle()->getFont()->setBold(true);

        $conditional3 = new Conditional();
        $conditional3->setConditionType(Conditional::CONDITION_CELLIS);
        $conditional3->setOperatorType(Conditional::OPERATOR_GREATERTHAN);
        $conditional3->addCondition('0');
        $conditional3->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_GREEN);
        $conditional3->getStyle()->getFont()->setBold(true);

        $conditionalStyles = $this->spreadsheet->getActiveSheet()->getStyle('A1:C3')->getConditionalStyles();
        $conditionalStyles[] = $conditional1;
        $conditionalStyles[] = $conditional2;
        $conditionalStyles[] = $conditional3;

        $this->spreadsheet->getActiveSheet()->getStyle('A1:C3')->setConditionalStyles($conditionalStyles);

        $this->spreadsheet->getActiveSheet()
            ->duplicateConditionalStyle(
                $this->spreadsheet->getActiveSheet()->getConditionalStyles('A1:C3'),
                'F1'
            );
    }

    /**
     * @dataProvider cellConditionalStylesProvider
     */
    public function testCellHasConditionalStyles(string $cellReference, bool $expectedHasConditionalStyles): void
    {
        $cellHasConditionalStyles = $this->spreadsheet->getActiveSheet()->conditionalStylesExists($cellReference);

        self::assertSame($expectedHasConditionalStyles, $cellHasConditionalStyles);
    }

    /**
     * @dataProvider cellConditionalStylesProvider
     */
    public function testCellGetConditionalStyles(string $cellReference, bool $expectedGetConditionalStyles): void
    {
        $cellHasConditionalStyles = $this->spreadsheet->getActiveSheet()->getConditionalStyles($cellReference);

        self::assertSame($expectedGetConditionalStyles, !empty($cellHasConditionalStyles));
    }

    public static function cellConditionalStylesProvider(): array
    {
        return [
            ['A1', true],
            ['B2', true],
            ['B4', false],
            ['A1:C3', true],
            ['A1:B2', false],
            ['F1', true],
            ['F2', false],
            ['A1:F1', false],
        ];
    }
}
 ?>

Did this file decode correctly?

Original Code

<?php

declare(strict_types=1);

namespace PhpOffice\PhpSpreadsheetTests\Worksheet;

use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Style\Color;
use PhpOffice\PhpSpreadsheet\Style\Conditional;
use PHPUnit\Framework\TestCase;

class ConditionalStyleTest extends TestCase
{
    protected Spreadsheet $spreadsheet;

    protected function setUp(): void
    {
        parent::setUp();

        $this->spreadsheet = new Spreadsheet();

        $conditional1 = new Conditional();
        $conditional1->setConditionType(Conditional::CONDITION_CELLIS);
        $conditional1->setOperatorType(Conditional::OPERATOR_LESSTHAN);
        $conditional1->addCondition('0');
        $conditional1->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_RED);
        $conditional1->getStyle()->getFont()->setBold(true);

        $conditional2 = new Conditional();
        $conditional2->setConditionType(Conditional::CONDITION_CELLIS);
        $conditional2->setOperatorType(Conditional::OPERATOR_EQUAL);
        $conditional2->addCondition('0');
        $conditional2->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_YELLOW);
        $conditional2->getStyle()->getFont()->setBold(true);

        $conditional3 = new Conditional();
        $conditional3->setConditionType(Conditional::CONDITION_CELLIS);
        $conditional3->setOperatorType(Conditional::OPERATOR_GREATERTHAN);
        $conditional3->addCondition('0');
        $conditional3->getStyle()->getFont()->getColor()->setARGB(Color::COLOR_GREEN);
        $conditional3->getStyle()->getFont()->setBold(true);

        $conditionalStyles = $this->spreadsheet->getActiveSheet()->getStyle('A1:C3')->getConditionalStyles();
        $conditionalStyles[] = $conditional1;
        $conditionalStyles[] = $conditional2;
        $conditionalStyles[] = $conditional3;

        $this->spreadsheet->getActiveSheet()->getStyle('A1:C3')->setConditionalStyles($conditionalStyles);

        $this->spreadsheet->getActiveSheet()
            ->duplicateConditionalStyle(
                $this->spreadsheet->getActiveSheet()->getConditionalStyles('A1:C3'),
                'F1'
            );
    }

    /**
     * @dataProvider cellConditionalStylesProvider
     */
    public function testCellHasConditionalStyles(string $cellReference, bool $expectedHasConditionalStyles): void
    {
        $cellHasConditionalStyles = $this->spreadsheet->getActiveSheet()->conditionalStylesExists($cellReference);

        self::assertSame($expectedHasConditionalStyles, $cellHasConditionalStyles);
    }

    /**
     * @dataProvider cellConditionalStylesProvider
     */
    public function testCellGetConditionalStyles(string $cellReference, bool $expectedGetConditionalStyles): void
    {
        $cellHasConditionalStyles = $this->spreadsheet->getActiveSheet()->getConditionalStyles($cellReference);

        self::assertSame($expectedGetConditionalStyles, !empty($cellHasConditionalStyles));
    }

    public static function cellConditionalStylesProvider(): array
    {
        return [
            ['A1', true],
            ['B2', true],
            ['B4', false],
            ['A1:C3', true],
            ['A1:B2', false],
            ['F1', true],
            ['F2', false],
            ['A1:F1', false],
        ];
    }
}

Function Calls

None

Variables

None

Stats

MD5 b6e2b9b3ef561a8f522f45e1e852e45e
Eval Count 0
Decode Time 88 ms