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\Reader\Xlsx; use..

Decoded Output download

<?php

declare(strict_types=1);

namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx;

use PhpOffice\PhpSpreadsheet\Reader\Xlsx\AutoFilter;
use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter as WorksheetAutoFilter;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
use PHPUnit\Framework\TestCase;
use SimpleXMLElement;

class AutoFilterTest extends TestCase
{
    private function getXMLInstance(string $ref): SimpleXMLElement
    {
        return new SimpleXMLElement(
            '<?xml version="1.0" encoding="UTF-8"?>'
            . '<root>'
                . '<autoFilter ref="' . $ref . '"></autoFilter>'
            . '</root>'
        );
    }

    public static function loadDataProvider(): array
    {
        return [
            ['$B3$E8', 0, 'B3E8'],
            ['$B3:$E8', 1, 'B3:E8'],
        ];
    }

    /**
     * @dataProvider loadDataProvider
     */
    public function testLoad(string $ref, int $expectedReadAutoFilterCalled, string $expectedRef): void
    {
        $worksheetAutoFilter = $this->getMockBuilder(WorksheetAutoFilter::class)
            ->disableOriginalConstructor()
            ->getMock();
        $worksheetAutoFilter->expects(self::exactly($expectedReadAutoFilterCalled ? 1 : 0))
            ->method('setRange')
            ->with($expectedRef);

        $worksheet = $this->getMockBuilder(Worksheet::class)
            ->disableOriginalConstructor()
            ->getMock();
        $worksheet->expects(self::exactly($expectedReadAutoFilterCalled ? 1 : 0))
            ->method('getAutoFilter')
            ->willReturn($worksheetAutoFilter);

        $autoFilter = new AutoFilter($worksheet, $this->getXMLInstance($ref));

        $autoFilter->load();
    }
}

Did this file decode correctly?

Original Code

<?php

declare(strict_types=1);

namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx;

use PhpOffice\PhpSpreadsheet\Reader\Xlsx\AutoFilter;
use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter as WorksheetAutoFilter;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
use PHPUnit\Framework\TestCase;
use SimpleXMLElement;

class AutoFilterTest extends TestCase
{
    private function getXMLInstance(string $ref): SimpleXMLElement
    {
        return new SimpleXMLElement(
            '<?xml version="1.0" encoding="UTF-8"?>'
            . '<root>'
                . '<autoFilter ref="' . $ref . '"></autoFilter>'
            . '</root>'
        );
    }

    public static function loadDataProvider(): array
    {
        return [
            ['$B3$E8', 0, 'B3E8'],
            ['$B3:$E8', 1, 'B3:E8'],
        ];
    }

    /**
     * @dataProvider loadDataProvider
     */
    public function testLoad(string $ref, int $expectedReadAutoFilterCalled, string $expectedRef): void
    {
        $worksheetAutoFilter = $this->getMockBuilder(WorksheetAutoFilter::class)
            ->disableOriginalConstructor()
            ->getMock();
        $worksheetAutoFilter->expects(self::exactly($expectedReadAutoFilterCalled ? 1 : 0))
            ->method('setRange')
            ->with($expectedRef);

        $worksheet = $this->getMockBuilder(Worksheet::class)
            ->disableOriginalConstructor()
            ->getMock();
        $worksheet->expects(self::exactly($expectedReadAutoFilterCalled ? 1 : 0))
            ->method('getAutoFilter')
            ->willReturn($worksheetAutoFilter);

        $autoFilter = new AutoFilter($worksheet, $this->getXMLInstance($ref));

        $autoFilter->load();
    }
}

Function Calls

None

Variables

None

Stats

MD5 cfeb6b4d7b9ba262b636cf2ca0e4aa7c
Eval Count 0
Decode Time 109 ms