HEX
Server: Apache/2.4.57 (Ubuntu) mod_fcgid/2.3.9 OpenSSL/3.0.2
System: Linux vmi267337.contaboserver.net 5.15.0-25-generic #25-Ubuntu SMP Wed Mar 30 15:54:22 UTC 2022 x86_64
User: ohirex (1008)
PHP: 8.2.8
Disabled: 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_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,exec,system,passthru,shell_exec
Upload Files
File: /home/ohirex/web/ohirex.com/public_html/join/abtests/Calculator/Variation.php
<?php

namespace BenTools\SplitTestAnalyzer;

final class Variation
{
    /**
     * @var string|int
     */
    private $key;

    /**
     * @var int
     */
    private $nbTotalActions;

    /**
     * @var int
     */
    private $nbSuccessfulActions;

    /**
     * Version constructor.
     * @param string $key
     * @param int    $nbTotalActions
     * @param int    $nbSuccessfulActions
     * @throws \InvalidArgumentException
     */
    public function __construct(string $key, int $nbTotalActions, int $nbSuccessfulActions)
    {
        $this->key = $key;
        $this->nbTotalActions = max(0, $nbTotalActions);
        $this->nbSuccessfulActions = max(0, $nbSuccessfulActions);
        if ($this->nbSuccessfulActions > $this->nbTotalActions) {
            throw new \InvalidArgumentException("The number of successful actions should not exceed the total number of actions.");
        }
    }

    /**
     * @return string|int
     */
    public function getKey(): string
    {
        return $this->key;
    }

    /**
     * @return int
     */
    public function getNbSuccesses(): int
    {
        return $this->nbSuccessfulActions;
    }

    /**
     * @return int
     */
    public function getNbFailures(): int
    {
        $result = $this->nbTotalActions - $this->nbSuccessfulActions;
        return $result;
    }

    public function __toString()
    {
        return $this->key;
    }
}