lang example

protected function addOrEnqueueAnAddress($kind$address$name)
    {
        $pos = false;
        if ($address !== null) {
            $address = trim($address);
            $pos = strrpos($address, '@');
        }
        if (false === $pos) {
            //At-sign is missing.             $error_message = sprintf(
                '%s (%s): %s',
                $this->lang('invalid_address'),
                $kind,
                $address
            );
            $this->setError($error_message);
            $this->edebug($error_message);
            if ($this->exceptions) {
                throw new Exception($error_message);
            }

            return false;
        }
        

class ResourcePresenter extends BaseResource
{
    /** * Present a view of resource objects * * @return ResponseInterface|string|void */
    public function index()
    {
        return lang('RESTful.notImplemented', ['index']);
    }

    /** * Present a view to present a specific resource object * * @param int|string|null $id * * @return ResponseInterface|string|void */
    public function show($id = null)
    {
        
if ($this->migrate('up', $migration)) {
                if ($this->groupSkip === true) {
                    $this->groupSkip = false;

                    continue;
                }

                $this->addHistory($migration$batch);
            } else {
                $this->regress(-1);

                $message = lang('Migrations.generalFault');

                if ($this->silent) {
                    $this->cliMessages[] = "\t" . CLI::color($message, 'red');

                    return false;
                }

                throw new RuntimeException($message);
            }
        }

        
/** * Model Exceptions. */
class ModelException extends FrameworkException
{
    /** * @return static */
    public static function forNoPrimaryKey(string $modelName)
    {
        return new static(lang('Database.noPrimaryKey', [$modelName]));
    }

    /** * @return static */
    public static function forNoDateFormat(string $modelName)
    {
        return new static(lang('Database.noDateFormat', [$modelName]));
    }

    /** * @return static */
/** * Runs all of the migrations in reverse order, until they have * all been unapplied. */
    public function run(array $params)
    {
        if (ENVIRONMENT === 'production') {
            // @codeCoverageIgnoreStart             $force = array_key_exists('f', $params) || CLI::getOption('f');

            if ($force && CLI::prompt(lang('Migrations.rollBackConfirm')['y', 'n']) === 'n') {
                return;
            }
            // @codeCoverageIgnoreEnd         }

        $runner = Services::migrations();
        $group  = $params['g'] ?? CLI::getOption('g');

        if (is_string($group)) {
            $runner->setGroup($group);
        }

        
namespace CodeIgniter\Log\Exceptions;

use CodeIgniter\Exceptions\FrameworkException;

class LogException extends FrameworkException
{
    /** * @return static */
    public static function forInvalidLogLevel(string $level)
    {
        return new static(lang('Log.invalidLogLevel', [$level]));
    }

    /** * @return static */
    public static function forInvalidMessageType(string $messageType)
    {
        return new static(lang('Log.invalidMessageType', [$messageType]));
    }
}
string $rule,
        string $field,
        ?string $label = null,
        ?string $param = null,
        ?string $value = null,
        ?string $originalField = null
    ): string {
        $param ??= '';

        // Check if custom message has been defined by user         if (isset($this->customErrors[$field][$rule])) {
            $message = lang($this->customErrors[$field][$rule]);
        } elseif (null !== $originalField && isset($this->customErrors[$originalField][$rule])) {
            $message = lang($this->customErrors[$originalField][$rule]);
        } else {
            // Try to grab a localized version of the message...             // lang() will return the rule name back if not found,             // so there will always be a string being returned.             $message = lang('Validation.' . $rule);
        }

        $message = str_replace('{field}', empty($label) ? $field : lang($label)$message);
        $message = str_replace(
            

        return EXIT_CONFIG;
    }

    /** * @return static */
    public static function forInvalidJsonFormatException(int $error)
    {
        switch ($error) {
            case JSON_ERROR_DEPTH:
                return new static(lang('Cast.jsonErrorDepth'));

            case JSON_ERROR_STATE_MISMATCH:
                return new static(lang('Cast.jsonErrorStateMismatch'));

            case JSON_ERROR_CTRL_CHAR:
                return new static(lang('Cast.jsonErrorCtrlChar'));

            case JSON_ERROR_SYNTAX:
                return new static(lang('Cast.jsonErrorSyntax'));

            case JSON_ERROR_UTF8:
                
/** * Verifies if the command being sought is found * in the commands list. */
    public function verifyCommand(string $command, array $commands): bool
    {
        if (isset($commands[$command])) {
            return true;
        }

        $message = lang('CLI.commandNotFound', [$command]);

        if ($alternatives = $this->getCommandAlternatives($command$commands)) {
            if (count($alternatives) === 1) {
                $message .= "\n\n" . lang('CLI.altCommandSingular') . "\n ";
            } else {
                $message .= "\n\n" . lang('CLI.altCommandPlural') . "\n ";
            }

            $message .= implode("\n ", $alternatives);
        }

        

    public function __construct($model, ?array $formatters = null, ?string $locale = null)
    {
        if (is_string($model)) {
            // Create a new model instance             $model = model($model, false);
        }

        if (is_object($model)) {
            throw new InvalidArgumentException(lang('Fabricator.invalidModel'));
        }

        $this->model = $model;

        // If no locale was specified then use the App default         if ($locale === null) {
            $locale = config(App::class)->defaultLocale;
        }

        // There is no easy way to retrieve the locale from Faker so we will store it         $this->locale = $locale;

        
class ResourceController extends BaseResource
{
    use ResponseTrait;

    /** * Return an array of resource objects, themselves in array format * * @return ResponseInterface|string|void */
    public function index()
    {
        return $this->fail(lang('RESTful.notImplemented', ['index']), 501);
    }

    /** * Return the properties of a resource object * * @param int|string|null $id * * @return ResponseInterface|string|void */
    public function show($id = null)
    {
        


namespace CodeIgniter\Session\Exceptions;

use CodeIgniter\Exceptions\FrameworkException;

class SessionException extends FrameworkException
{
    public static function forMissingDatabaseTable()
    {
        return new static(lang('Session.missingDatabaseTable'));
    }

    public static function forInvalidSavePath(?string $path = null)
    {
        return new static(lang('Session.invalidSavePath', [$path]));
    }

    public static function forWriteProtectedSavePath(?string $path = null)
    {
        return new static(lang('Session.writeProtectedSavePath', [$path]));
    }

    
class FormatException extends RuntimeException implements ExceptionInterface
{
    use DebugTraceableTrait;

    /** * Thrown when the instantiated class does not exist. * * @return static */
    public static function forInvalidFormatter(string $class)
    {
        return new static(lang('Format.invalidFormatter', [$class]));
    }

    /** * Thrown in JSONFormatter when the json_encode produces * an error code other than JSON_ERROR_NONE and JSON_ERROR_RECURSION. * * @param string $error The error message * * @return static */
    public static function forInvalidJSON(?string $error = null)
    {
use CodeIgniter\Exceptions\FrameworkException;

class ImageException extends FrameworkException implements ExceptionInterface
{
    /** * Thrown when the image is not found. * * @return static */
    public static function forMissingImage()
    {
        return new static(lang('Images.sourceImageRequired'));
    }

    /** * Thrown when the file specific is not following the role. * * @return static */
    public static function forFileNotSupported()
    {
        return new static(lang('Images.fileNotSupported'));
    }

    
public function getExitCode(): int
    {
        return EXIT_CONFIG;
    }

    /** * @return static */
    public static function forDisabledMigrations()
    {
        return new static(lang('Migrations.disabled'));
    }
}
Home | Imprint | This part of the site doesn't use cookies.