-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from OpenClassrooms/ADD_LOG
Add log 🐼
- Loading branch information
Showing
95 changed files
with
1,600 additions
and
299 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.idea/ | ||
composer.lock | ||
composer.phar | ||
vendor/ |
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
language: php | ||
|
||
php: | ||
- "5.3" | ||
- "5.4" | ||
- "5.5" | ||
- "5.6" | ||
|
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
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
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 |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
*/ | ||
class Cache | ||
{ | ||
|
||
/** | ||
* @var string | ||
*/ | ||
|
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
132 changes: 132 additions & 0 deletions
132
src/OpenClassrooms/UseCase/Application/Annotations/Log.php
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,132 @@ | ||
<?php | ||
|
||
namespace OpenClassrooms\UseCase\Application\Annotations; | ||
|
||
use Psr\Log\LogLevel; | ||
|
||
/** | ||
* @author Romain Kuzniak <romain.kuzniak@turn-it-up.org> | ||
* @Annotation | ||
*/ | ||
class Log | ||
{ | ||
const PRE_METHOD = 'pre'; | ||
|
||
const POST_METHOD = 'post'; | ||
|
||
const ON_EXCEPTION_METHOD = 'onException'; | ||
|
||
const DEFAULT_METHOD = self::ON_EXCEPTION_METHOD; | ||
|
||
const DEFAULT_LEVEL = LogLevel::WARNING; | ||
|
||
/** | ||
* @var string[] | ||
*/ | ||
private static $allowedMethods = array( | ||
self::PRE_METHOD, | ||
self::POST_METHOD, | ||
self::ON_EXCEPTION_METHOD, | ||
); | ||
|
||
/** | ||
* @var string[] | ||
*/ | ||
private static $allowedLevels = array( | ||
LogLevel::ALERT, | ||
LogLevel::CRITICAL, | ||
LogLevel::DEBUG, | ||
LogLevel::EMERGENCY, | ||
LogLevel::ERROR, | ||
LogLevel::INFO, | ||
LogLevel::NOTICE, | ||
LogLevel::WARNING, | ||
); | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public $level = self::DEFAULT_LEVEL; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
public $message; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
public $context = array(); | ||
|
||
/** | ||
* @var string[] | ||
*/ | ||
public $methods = array(self::DEFAULT_METHOD); | ||
|
||
public function __construct(array $values) | ||
{ | ||
if (isset($values['level'])) { | ||
$this->level = $values['level']; | ||
if (!in_array($this->level, self::$allowedLevels)) { | ||
throw new \InvalidArgumentException( | ||
'Level "'.$this->level.'" is not a valid PSR level. See Psr\Log\LogLevel.' | ||
); | ||
} | ||
} | ||
|
||
if (isset($values['methods'])) { | ||
$this->methods = is_array($values['methods']) ? $values['methods'] : | ||
array_map('trim', explode(',', $values['methods'])); | ||
} | ||
|
||
foreach ($this->methods as $method) { | ||
if (!in_array($method, self::$allowedMethods)) { | ||
throw new \InvalidArgumentException( | ||
'Method "'.$method.'" is not allowed. Allowed: pre, post and onException' | ||
); | ||
} | ||
} | ||
|
||
if (isset($values['message'])) { | ||
$this->message = $values['message']; | ||
} | ||
|
||
if (isset($values['context'])) { | ||
if (is_array($values['context'])) { | ||
$this->context = $values['context']; | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
public function getMethods() | ||
{ | ||
return $this->methods; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getLevel() | ||
{ | ||
return $this->level; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getContext() | ||
{ | ||
return $this->context; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getMessage() | ||
{ | ||
return $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 |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
*/ | ||
class Security | ||
{ | ||
|
||
/** | ||
* @var mixed | ||
*/ | ||
|
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
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
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 |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
*/ | ||
class CacheProxyStrategyRequestDTO implements CacheProxyStrategyRequest | ||
{ | ||
|
||
/** | ||
* @var int | ||
*/ | ||
|
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 |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
*/ | ||
class CacheProxyStrategyBagImpl extends ProxyStrategyBag | ||
{ | ||
|
||
/** | ||
* @var CacheProxyStrategy | ||
*/ | ||
|
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 |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
*/ | ||
class ProxyStrategyResponseDTO implements ProxyStrategyResponse | ||
{ | ||
|
||
/** | ||
* @var string | ||
*/ | ||
|
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
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 |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
*/ | ||
class EventProxyStrategyRequestDTO implements EventProxyStrategyRequest | ||
{ | ||
|
||
/** | ||
* @var string | ||
*/ | ||
|
Oops, something went wrong.