Skip to content

Commit

Permalink
improve PHPDoc and Exception usage
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoColomb committed Nov 28, 2017
1 parent c8ad874 commit bb357e3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion includes/Admin/Logger.php
Expand Up @@ -14,7 +14,7 @@ class Logger extends \Aura\Sql\Profiler {


/** /**
* the YDB instance * the YDB instance
* @var YOURLS\Database\YDB * @var YDB
*/ */
protected $ydb; protected $ydb;


Expand Down
10 changes: 7 additions & 3 deletions includes/Config/Config.php
Expand Up @@ -6,6 +6,8 @@


namespace YOURLS\Config; namespace YOURLS\Config;


use YOURLS\Exceptions\ConfigException;

class Config { class Config {


/** /**
Expand Down Expand Up @@ -61,6 +63,7 @@ public function set_root($root) {
* *
* @since 1.7.3 * @since 1.7.3
* @return string path to found config file * @return string path to found config file
* @throws ConfigException
*/ */
public function find_config() { public function find_config() {


Expand All @@ -71,7 +74,7 @@ public function find_config() {
} }


if (!empty($config) && !is_readable($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/ // config.php in /user/
Expand All @@ -86,21 +89,22 @@ public function find_config() {


// config.php not found :( // 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 * Define core constants that have not been user defined in config.php
* *
* @since 1.7.3 * @since 1.7.3
* @return void * @return void
* @throws ConfigException
*/ */
public function define_core_constants() { public function define_core_constants() {
// Check minimal config job has been properly done // 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'); $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) { foreach($must_haves as $must_have) {
if (!defined($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');
} }
} }


Expand Down
2 changes: 2 additions & 0 deletions includes/Config/Init.php
Expand Up @@ -15,6 +15,8 @@ class Init {


/** /**
* @since 1.7.3 * @since 1.7.3
*
* @param InitDefaults $actions
*/ */
public function __construct(InitDefaults $actions) { public function __construct(InitDefaults $actions) {


Expand Down
4 changes: 4 additions & 0 deletions includes/Database/YDB.php
Expand Up @@ -135,6 +135,7 @@ public function get_emulate_state() {
* *
* @since 1.7.3 * @since 1.7.3
* @return void * @return void
* @throws \PDOException
*/ */
public function connect_to_DB() { public function connect_to_DB() {
try { try {
Expand All @@ -148,6 +149,9 @@ public function connect_to_DB() {
* Die with an error message * Die with an error message
* *
* @since 1.7.3 * @since 1.7.3
*
* @param \Exception $exception
*
* @return void * @return void
*/ */
public function dead_or_error(\Exception $exception) { public function dead_or_error(\Exception $exception) {
Expand Down

0 comments on commit bb357e3

Please sign in to comment.