HEX
Server: Apache
System: Linux d5123.usc1.stableserver.net 5.14.0-570.17.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Sat May 24 12:53:17 EDT 2025 x86_64
User: d5123 (1001)
PHP: 8.4.21
Disabled: NONE
Upload Files
File: /home/d5123/myboofola_com/wp-content/plugins/site-reviews/plugin/Defaults/ToggleStatusDefaults.php
<?php

namespace GeminiLabs\SiteReviews\Defaults;

class ToggleStatusDefaults extends DefaultsAbstract
{
    /**
     * The values that should be cast before sanitization is run.
     * This is done before $sanitize and $enums.
     */
    public array $casts = [
        'post_id' => 'int',
        'status' => 'string',
    ];

    /**
     * The values that should be constrained after sanitization is run.
     * This is done after $casts and $sanitize.
     */
    public array $enums = [
        'status' => ['approve', 'pending', 'publish', 'unapprove'],
    ];

    protected function defaults(): array
    {
        return [
            'post_id' => 0,
            'status' => '',
        ];
    }

    /**
     * Finalize provided values, this always runs last.
     */
    protected function finalize(array $values = []): array
    {
        $values['status'] = in_array($values['status'], ['approve', 'publish'])
            ? 'publish'
            : 'pending';
        return $values;
    }
}