JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr{ gilour

File "PhishtankCredentialsValidator.php"

Full Path: /home/markqprx/iniasli.pro/app-20260222054640/Admin/PhishtankCredentialsValidator.php
File size: 1002 B
MIME-type: text/x-php
Charset: utf-8

<?php

namespace App\Admin;

use Common\Domains\Validation\ValidateLinkWithPhishtank;
use Common\Settings\Settings;
use Exception;

class PhishtankCredentialsValidator
{
    const KEYS = ['links.phishtank_key'];

    public function fails($settings)
    {
        app(Settings::class)->set('links.phishtank_key', $settings['links.phishtank_key']);

        try {
            $valid = app(ValidateLinkWithPhishtank::class)->execute(
                'https://google.com',
            );
            if ($valid !== true) {
                return [
                    'phishtank_group' => 'This API key is not valid.',
                ];
            }
        } catch (Exception $e) {
            return $this->getErrorMessage($e);
        }
    }

    private function getErrorMessage($e): array
    {
        if ($e->getCode() === 403) {
            $msg = 'This API key is not valid.';
        } else {
            $msg = $e->getMessage();
        }
        return ['phishtank_group' => $msg];
    }
}