Permalink
Browse files

improve PHPDoc and Exception usage

  • Loading branch information...
LeoColomb committed Nov 28, 2017
1 parent c8ad874 commit bb357e3793f9b0ab41557c1b12dde131b9073343
Showing with 14 additions and 4 deletions.
  1. +1 −1 includes/Admin/Logger.php
  2. +7 −3 includes/Config/Config.php
  3. +2 −0 includes/Config/Init.php
  4. +4 −0 includes/Database/YDB.php
@@ -14,7 +14,7 @@ class Logger extends \Aura\Sql\Profiler {
/**
* the YDB instance
* @var YOURLS\Database\YDB
* @var YDB
*/
protected $ydb;
View
@@ -6,6 +6,8 @@
namespace YOURLS\Config;
use YOURLS\Exceptions\ConfigException;
class Config {
/**
@@ -61,6 +63,7 @@ public function set_root($root) {
*
* @since 1.7.3
* @return string path to found config file
* @throws ConfigException
*/
public function find_config() {
@@ -71,7 +74,7 @@ public function find_config() {
}
if (!empty($config) && !is_readable($config)) {
throw new \YOURLS\Exceptions\ConfigException("User defined config not found at '$config'");
throw new ConfigException("User defined config not found at '$config'");
}
// config.php in /user/
@@ -86,21 +89,22 @@ public function find_config() {
// config.php not found :(
throw new \YOURLS\Exceptions\ConfigException('Cannot find config.php. Please read the readme.html to learn how to install YOURLS');
throw new ConfigException('Cannot find config.php. Please read the readme.html to learn how to install YOURLS');
}
/**
* Define core constants that have not been user defined in config.php
*
* @since 1.7.3
* @return void
* @throws ConfigException
*/
public function define_core_constants() {
// Check minimal config job has been properly done
$must_haves = array('YOURLS_DB_USER', 'YOURLS_DB_PASS', 'YOURLS_DB_NAME', 'YOURLS_DB_HOST', 'YOURLS_DB_PREFIX', 'YOURLS_SITE');
foreach($must_haves as $must_have) {
if (!defined($must_have)) {
throw new \YOURLS\Exceptions\ConfigException('Config is incomplete (missing at least '.$must_have.') Check config-sample.php and edit your config accordingly');
throw new ConfigException('Config is incomplete (missing at least '.$must_have.') Check config-sample.php and edit your config accordingly');
}
}
View
@@ -15,6 +15,8 @@ class Init {
/**
* @since 1.7.3
*
* @param InitDefaults $actions
*/
public function __construct(InitDefaults $actions) {
@@ -135,6 +135,7 @@ public function get_emulate_state() {
*
* @since 1.7.3
* @return void
* @throws \PDOException
*/
public function connect_to_DB() {
try {
@@ -148,6 +149,9 @@ public function connect_to_DB() {
* Die with an error message
*
* @since 1.7.3
*
* @param \Exception $exception
*
* @return void
*/
public function dead_or_error(\Exception $exception) {

0 comments on commit bb357e3

Please sign in to comment.