-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
315 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
|
||
namespace Odan\Validation; | ||
|
||
/** | ||
* StatusMessage. | ||
* | ||
* Represents a alert status (success, danger, warning, info) and a status message. | ||
*/ | ||
class AlertMessage | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $status; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $message; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param string $status Alert status | ||
* @param string $message The message | ||
*/ | ||
public function __construct(string $status, string $message) | ||
{ | ||
$this->status = $status; | ||
$this->message = $message; | ||
} | ||
|
||
/** | ||
* Clone object. | ||
* | ||
* @param string $status Status code | ||
* @param string $message The message | ||
* | ||
* @return self | ||
*/ | ||
public function with(string $status, string $message): self | ||
{ | ||
return new self($status, $message); | ||
} | ||
|
||
/** | ||
* Returns the message. | ||
* | ||
* @return string The message | ||
*/ | ||
public function message(): string | ||
{ | ||
return $this->message; | ||
} | ||
|
||
/** | ||
* Returns the status code. | ||
* | ||
* @return string The status | ||
*/ | ||
public function status(): string | ||
{ | ||
return $this->status; | ||
} | ||
|
||
/** | ||
* Convert to array. | ||
* | ||
* @return array Data | ||
*/ | ||
public function toArray(): array | ||
{ | ||
return [ | ||
'status' => $this->status(), | ||
'message' => $this->message(), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace Odan\Validation; | ||
|
||
/** | ||
* AlertStatus. | ||
* | ||
* Can be used in combination with AlertMessage. | ||
*/ | ||
class AlertMessageStatus | ||
{ | ||
// Bootstrap | ||
const PRIMARY = 'primary'; | ||
|
||
// Bootstrap | ||
const SECONDARY = 'secondary'; | ||
|
||
// Bootstrap | ||
const SUCCESS = 'success'; | ||
|
||
// Bootstrap | ||
const DANGER = 'danger'; | ||
|
||
// Bootstrap | ||
const LIGHT = 'light'; | ||
|
||
// Bootstrap | ||
const DARK = 'dark'; | ||
|
||
// RFC 5424 | ||
const DEBUG = 'debug'; | ||
|
||
// RFC 5424 and Bootstrap | ||
const INFO = 'info'; | ||
|
||
const NOTICE = 'notice'; | ||
|
||
// RFC 5424 and Bootstrap | ||
const WARNING = 'warning'; | ||
|
||
// RFC 5424 | ||
const ERROR = 'error'; | ||
|
||
// RFC 5424 | ||
const CRITICAL = 'critical'; | ||
|
||
// RFC 5424 | ||
const ALERT = 'alert'; | ||
|
||
// RFC 5424 | ||
const EMERGENCY = 'emergency'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
|
||
namespace Odan\Validation; | ||
|
||
/** | ||
* StatusMessage. | ||
* | ||
* Represents a numeric status code and a status message. | ||
*/ | ||
class StatusMessage | ||
{ | ||
/** | ||
* @var int | ||
*/ | ||
protected $status = 0; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $message; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param int $status Status code | ||
* @param string $message The message | ||
*/ | ||
public function __construct(int $status, string $message) | ||
{ | ||
$this->status = $status; | ||
$this->message = $message; | ||
} | ||
|
||
/** | ||
* Clone object. | ||
* | ||
* @param int $status Status code | ||
* @param string $message The message | ||
* | ||
* @return self | ||
*/ | ||
public function with(int $status, string $message): self | ||
{ | ||
return new self($status, $message); | ||
} | ||
|
||
/** | ||
* Returns the message. | ||
* | ||
* @return string The message | ||
*/ | ||
public function message(): string | ||
{ | ||
return $this->message; | ||
} | ||
|
||
/** | ||
* Returns the status code. | ||
* | ||
* @return int The status code | ||
*/ | ||
public function status(): int | ||
{ | ||
return $this->status; | ||
} | ||
|
||
/** | ||
* Convert to array. | ||
* | ||
* @return array Data | ||
*/ | ||
public function toArray(): array | ||
{ | ||
return [ | ||
'status' => $this->status(), | ||
'message' => $this->message(), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
|
||
namespace Odan\Validation; | ||
|
||
/** | ||
* SuccessMessage. | ||
* | ||
* Represents a boolean success status and a success message. | ||
*/ | ||
class SuccessMessage | ||
{ | ||
/** | ||
* @var bool | ||
*/ | ||
protected $success = false; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $message = null; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param bool $success Success | ||
* @param string $message Message | ||
*/ | ||
public function __construct(bool $success, string $message) | ||
{ | ||
$this->success = $success; | ||
$this->message = $message; | ||
} | ||
|
||
/** | ||
* Get message. | ||
* | ||
* @param bool $success | ||
* @param string $message | ||
* | ||
* @return self | ||
*/ | ||
public function with(bool $success, string $message): self | ||
{ | ||
return new self($success, $message); | ||
} | ||
|
||
/** | ||
* Returns the message. | ||
* | ||
* @return string | ||
*/ | ||
public function message(): string | ||
{ | ||
return $this->message; | ||
} | ||
|
||
/** | ||
* Returns the success status. | ||
* | ||
* @return bool The success status | ||
*/ | ||
public function success(): bool | ||
{ | ||
return $this->success; | ||
} | ||
|
||
/** | ||
* Returns the failed status. | ||
* | ||
* @return bool The failed status | ||
*/ | ||
public function failed(): bool | ||
{ | ||
return !$this->success; | ||
} | ||
|
||
/** | ||
* Convert to array. | ||
* | ||
* @return array Data | ||
*/ | ||
public function toArray(): array | ||
{ | ||
return [ | ||
'success' => $this->success(), | ||
'message' => $this->message(), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.