summaryrefslogtreecommitdiffstats
path: root/app/classes/PlanetError.php
blob: e47ab1d665f8d4ab89232f75eb69bf44e3b5219d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php

class PlanetError
{
    public $level;
    public $levels = array(
        1 => 'notice',
        2 => 'warning',
        3 => 'error',
    );
    public $message;

    /**
     * PlanetError constructor.
     * @param $level
     * @param $message
     */
    public function __construct($level, $message)
    {
        $this->level = (int) $level;
        $this->message = $message;
    }

    /**
     * @param  string $format
     * @return string
     */
    public function toString($format = '%1$s: %2$s')
    {
        return sprintf($format, $this->levels[$this->level], $this->message);
    }
}