| 1 |
<?php |
| 2 |
|
| 3 |
namespace Depicter\Services; |
| 4 |
|
| 5 |
class AuthenticationService { |
| 6 |
|
| 7 |
/** |
| 8 |
* Retrieves client's tier |
| 9 |
* |
| 10 |
* @return string |
| 11 |
*/ |
| 12 |
public function getTier(){ |
| 13 |
return \Depicter::options()->get('user_tier', 'free-user') ?: 'free-user'; |
| 14 |
} |
| 15 |
|
| 16 |
/** |
| 17 |
* Whether client has not free tier or not |
| 18 |
* |
| 19 |
* @return bool |
| 20 |
*/ |
| 21 |
public function isPaid(){ |
| 22 |
return $this->getTier() !== 'free-user'; |
| 23 |
} |
| 24 |
|
| 25 |
/** |
| 26 |
* Verify if it is an activated installation or not |
| 27 |
* |
| 28 |
* @return bool |
| 29 |
*/ |
| 30 |
public function verifyActivation(){ |
| 31 |
return \Depicter::client()->validateActivation(); |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Whether it is an activated installation or not |
| 36 |
* |
| 37 |
* @return bool |
| 38 |
*/ |
| 39 |
public function isActivated(){ |
| 40 |
return $this->getActivationStatus() === 'activated'; |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Retrieves subscription activation status |
| 45 |
* |
| 46 |
* @return string |
| 47 |
*/ |
| 48 |
public function getActivationStatus(){ |
| 49 |
$activationStatus = \Depicter::options()->get('subscription_status', 'not-activated'); |
| 50 |
$activationError = \Depicter::options()->get('activation_error_message', ''); |
| 51 |
return ( 'activated' !== $activationStatus ) && ! empty( $activationError ) ? 'error': $activationStatus; |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* Get client key |
| 56 |
* |
| 57 |
* @return string |
| 58 |
*/ |
| 59 |
public function getClientKey(){ |
| 60 |
return \Depicter::options()->get( 'client_key', '' ); |
| 61 |
} |
| 62 |
} |
| 63 |
|