From b59106dc64131c3773afce173a7cae73a7063a73 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sat, 9 Apr 2016 15:27:44 +0100 Subject: [PATCH] Added ClientTrait --- examples/src/Entities/ClientEntity.php | 77 +------------------------- src/Entities/Traits/ClientTrait.php | 32 +++++++++++ 2 files changed, 34 insertions(+), 75 deletions(-) create mode 100644 src/Entities/Traits/ClientTrait.php diff --git a/examples/src/Entities/ClientEntity.php b/examples/src/Entities/ClientEntity.php index cb3c51d0..36262646 100644 --- a/examples/src/Entities/ClientEntity.php +++ b/examples/src/Entities/ClientEntity.php @@ -3,83 +3,10 @@ namespace OAuth2ServerExamples\Entities; use League\OAuth2\Server\Entities\ClientEntityInterface; +use League\OAuth2\Server\Entities\Traits\ClientTrait; use League\OAuth2\Server\Entities\Traits\EntityTrait; class ClientEntity implements ClientEntityInterface { - use EntityTrait; - - private $name; - - private $secret; - - private $redirectUri; - - /** - * Get the client's name. - * - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Set the client's name. - * - * @param string $name - */ - public function setName($name) - { - $this->name = $name; - } - - /** - * @param string $secret - */ - public function setSecret($secret) - { - $this->secret = $secret; - } - - /** - * Get the hashed client secret - * - * @return string - */ - public function getSecret() - { - return $this->secret; - } - - /** - * Set the client's redirect uri. - * - * @param string $redirectUri - */ - public function setRedirectUri($redirectUri) - { - $this->redirectUri = $redirectUri; - } - - /** - * Returns the registered redirect URI. - * - * @return string - */ - public function getRedirectUri() - { - return $this->redirectUri; - } - - /** - * Returns true if the client is capable of keeping it's secrets secret. - * - * @return bool - */ - public function canKeepASecret() - { - return $this->secret !== null; - } + use EntityTrait, ClientTrait; } diff --git a/src/Entities/Traits/ClientTrait.php b/src/Entities/Traits/ClientTrait.php new file mode 100644 index 00000000..bf5fb97d --- /dev/null +++ b/src/Entities/Traits/ClientTrait.php @@ -0,0 +1,32 @@ +name; + } + + /** + * Returns the registered redirect URI (as a string). + * + * Alternatively return an indexed array of redirect URIs. + * + * @return string|string[] + */ + public function getRedirectUri() + { + return $this->redirectUri; + } +}