Completed
Branch master (1d7ebe)
by Wanderson
02:15
created

Alert::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 2
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Win\Alert;
4
5
use Win\Mvc\Block;
6
7
/**
8
 * Alertas
9
 * São mensagens armazenadas na sessão e exibidas ao usuário
10
 */
11
abstract class Alert {
12
13
	public $type;
14
	public $message;
15
16
	/**
17
	 * Cria um novo alerta
18
	 * @param string $type
19
	 * @param string $message
20
	 */
21
	public function __construct($type, $message) {
22
		$this->type = $type;
23
		$this->message = $message;
24
		Session::addAlert($this);
25
	}
26
27
	/** @return string */
28
	public function __toString() {
29
		return $this->message;
30
	}
31
32
	/**
33
	 * Exibe o conteúdo HTML do alerta
34
	 * @param Alert $alert
0 ignored issues
show
Bug introduced by
There is no parameter named $alert. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
35
	 */
36
	public function load() {
37
		$block = new Block('layout/html/alert', ['alert' => $this]);
38
		$block->load();
39
	}
40
41
	/**
42
	 * Cria um alerta de erro ou sucesso, dependendo dos parâmetros
43
	 * Possibilitando criar um "AlertError" ou "AlertSuccess" em um único método
44
	 * @param string $error
45
	 * @param string $success
46
	 * @return Alert
47
	 */
48
	public static function create($error, $success) {
49
		if (!is_null($error)) {
50
			return new AlertError($error);
51
		} else {
52
			return new AlertSuccess($success);
53
		}
54
	}
55
56
}
57