Passed
Push — master ( 9b803d...bcd4f7 )
by Goffy
03:19
created
class/Github/Storages/FileCache.php 1 patch
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -12,86 +12,86 @@
 block discarded – undo
12 12
  */
13 13
 class FileCache extends Github\Sanity implements ICache
14 14
 {
15
-	/** @var string */
16
-	private $dir;
17
-
18
-
19
-	/**
20
-	 * @param  string  temporary directory
21
-	 *
22
-	 * @throws MissingDirectoryException
23
-	 */
24
-	public function __construct($tempDir)
25
-	{
26
-		if (!is_dir($tempDir)) {
27
-			throw new MissingDirectoryException("Directory '$tempDir' is missing.");
28
-		}
29
-
30
-		$dir = $tempDir . DIRECTORY_SEPARATOR . 'milo.github-api';
31
-
32
-		if (!is_dir($dir)) {
33
-			set_error_handler(function($severity, $message, $file, $line) use ($dir, & $valid) {
34
-				restore_error_handler();
35
-				if (!is_dir($dir)) {
36
-					throw new MissingDirectoryException("Cannot create '$dir' directory.", 0, new \ErrorException($message, 0, $severity, $file, $line));
37
-				}
38
-			});
39
-			mkdir($dir);
40
-			restore_error_handler();
41
-		}
42
-
43
-		$this->dir = $dir;
44
-	}
45
-
46
-
47
-	/**
48
-	 * @param  string
49
-	 * @param  mixed
50
-	 * @return mixed  stored value
51
-	 */
52
-	public function save($key, $value)
53
-	{
54
-		file_put_contents(
55
-			$this->filePath($key),
56
-			serialize($value),
57
-			LOCK_EX
58
-		);
59
-
60
-		return $value;
61
-	}
62
-
63
-
64
-	/**
65
-	 * @param  string
66
-	 * @return mixed|NULL
67
-	 */
68
-	public function load($key)
69
-	{
70
-		$path = $this->filePath($key);
71
-		if (is_file($path) && ($fd = fopen($path, 'rb')) && flock($fd, LOCK_SH)) {
72
-			$cached = stream_get_contents($fd);
73
-			flock($fd, LOCK_UN);
74
-			fclose($fd);
75
-
76
-			$success = TRUE;
77
-			set_error_handler(function() use (& $success) { return $success = FALSE; }, E_NOTICE);
78
-			$cached = unserialize($cached);
79
-			restore_error_handler();
80
-
81
-			if ($success) {
82
-				return $cached;
83
-			}
84
-		}
85
-	}
86
-
87
-
88
-	/**
89
-	 * @param  string
90
-	 * @return string
91
-	 */
92
-	private function filePath($key)
93
-	{
94
-		return $this->dir . DIRECTORY_SEPARATOR . sha1($key) . '.php';
95
-	}
15
+    /** @var string */
16
+    private $dir;
17
+
18
+
19
+    /**
20
+     * @param  string  temporary directory
21
+     *
22
+     * @throws MissingDirectoryException
23
+     */
24
+    public function __construct($tempDir)
25
+    {
26
+        if (!is_dir($tempDir)) {
27
+            throw new MissingDirectoryException("Directory '$tempDir' is missing.");
28
+        }
29
+
30
+        $dir = $tempDir . DIRECTORY_SEPARATOR . 'milo.github-api';
31
+
32
+        if (!is_dir($dir)) {
33
+            set_error_handler(function($severity, $message, $file, $line) use ($dir, & $valid) {
34
+                restore_error_handler();
35
+                if (!is_dir($dir)) {
36
+                    throw new MissingDirectoryException("Cannot create '$dir' directory.", 0, new \ErrorException($message, 0, $severity, $file, $line));
37
+                }
38
+            });
39
+            mkdir($dir);
40
+            restore_error_handler();
41
+        }
42
+
43
+        $this->dir = $dir;
44
+    }
45
+
46
+
47
+    /**
48
+     * @param  string
49
+     * @param  mixed
50
+     * @return mixed  stored value
51
+     */
52
+    public function save($key, $value)
53
+    {
54
+        file_put_contents(
55
+            $this->filePath($key),
56
+            serialize($value),
57
+            LOCK_EX
58
+        );
59
+
60
+        return $value;
61
+    }
62
+
63
+
64
+    /**
65
+     * @param  string
66
+     * @return mixed|NULL
67
+     */
68
+    public function load($key)
69
+    {
70
+        $path = $this->filePath($key);
71
+        if (is_file($path) && ($fd = fopen($path, 'rb')) && flock($fd, LOCK_SH)) {
72
+            $cached = stream_get_contents($fd);
73
+            flock($fd, LOCK_UN);
74
+            fclose($fd);
75
+
76
+            $success = TRUE;
77
+            set_error_handler(function() use (& $success) { return $success = FALSE; }, E_NOTICE);
78
+            $cached = unserialize($cached);
79
+            restore_error_handler();
80
+
81
+            if ($success) {
82
+                return $cached;
83
+            }
84
+        }
85
+    }
86
+
87
+
88
+    /**
89
+     * @param  string
90
+     * @return string
91
+     */
92
+    private function filePath($key)
93
+    {
94
+        return $this->dir . DIRECTORY_SEPARATOR . sha1($key) . '.php';
95
+    }
96 96
 
97 97
 }
Please login to merge, or discard this patch.
class/Github/Storages/ICache.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -5,18 +5,18 @@
 block discarded – undo
5 5
 
6 6
 interface ICache
7 7
 {
8
-	/**
9
-	 * @param  string
10
-	 * @param  mixed
11
-	 * @return mixed  stored value
12
-	 */
13
-	function save($key, $value);
8
+    /**
9
+     * @param  string
10
+     * @param  mixed
11
+     * @return mixed  stored value
12
+     */
13
+    function save($key, $value);
14 14
 
15 15
 
16
-	/**
17
-	 * @param  string
18
-	 * @return mixed|NULL
19
-	 */
20
-	function load($key);
16
+    /**
17
+     * @param  string
18
+     * @return mixed|NULL
19
+     */
20
+    function load($key);
21 21
 
22 22
 }
Please login to merge, or discard this patch.
class/Github/Storages/ISessionStorage.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -8,25 +8,25 @@
 block discarded – undo
8 8
  */
9 9
 interface ISessionStorage
10 10
 {
11
-	/**
12
-	 * @param  string
13
-	 * @param  mixed
14
-	 * @return self
15
-	 */
16
-	function set($name, $value);
17
-
18
-
19
-	/**
20
-	 * @param  string
21
-	 * @return mixed
22
-	 */
23
-	function get($name);
24
-
25
-
26
-	/**
27
-	 * @param  string
28
-	 * @return self
29
-	 */
30
-	function remove($name);
11
+    /**
12
+     * @param  string
13
+     * @param  mixed
14
+     * @return self
15
+     */
16
+    function set($name, $value);
17
+
18
+
19
+    /**
20
+     * @param  string
21
+     * @return mixed
22
+     */
23
+    function get($name);
24
+
25
+
26
+    /**
27
+     * @param  string
28
+     * @return self
29
+     */
30
+    function remove($name);
31 31
 
32 32
 }
Please login to merge, or discard this patch.
class/Github/Storages/SessionStorage.php 1 patch
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -12,75 +12,75 @@
 block discarded – undo
12 12
  */
13 13
 class SessionStorage extends Github\Sanity implements ISessionStorage
14 14
 {
15
-	const SESSION_KEY = 'milo.github-api';
16
-
17
-	/** @var string */
18
-	private $sessionKey;
19
-
20
-
21
-	/**
22
-	 * @param  string
23
-	 */
24
-	public function __construct($sessionKey = self::SESSION_KEY)
25
-	{
26
-		$this->sessionKey = $sessionKey;
27
-	}
28
-
29
-
30
-	/**
31
-	 * @param  string
32
-	 * @param  mixed
33
-	 * @return self
34
-	 */
35
-	public function set($name, $value)
36
-	{
37
-		if ($value === NULL) {
38
-			return $this->remove($name);
39
-		}
40
-
41
-		$this->check(__METHOD__);
42
-		$_SESSION[$this->sessionKey][$name] = $value;
43
-
44
-		return $this;
45
-	}
46
-
47
-
48
-	/**
49
-	 * @param  string
50
-	 * @return mixed
51
-	 */
52
-	public function get($name)
53
-	{
54
-		$this->check(__METHOD__);
55
-
56
-		return isset($_SESSION[$this->sessionKey][$name])
57
-			? $_SESSION[$this->sessionKey][$name]
58
-			: NULL;
59
-	}
60
-
61
-
62
-	/**
63
-	 * @param  string
64
-	 * @return self
65
-	 */
66
-	public function remove($name)
67
-	{
68
-		$this->check(__METHOD__);
69
-
70
-		unset($_SESSION[$this->sessionKey][$name]);
71
-
72
-		return $this;
73
-	}
74
-
75
-
76
-	/**
77
-	 * @param  string
78
-	 */
79
-	private function check($method)
80
-	{
81
-		if (!isset($_SESSION)) {
82
-			trigger_error("Start session before using $method().", E_USER_WARNING);
83
-		}
84
-	}
15
+    const SESSION_KEY = 'milo.github-api';
16
+
17
+    /** @var string */
18
+    private $sessionKey;
19
+
20
+
21
+    /**
22
+     * @param  string
23
+     */
24
+    public function __construct($sessionKey = self::SESSION_KEY)
25
+    {
26
+        $this->sessionKey = $sessionKey;
27
+    }
28
+
29
+
30
+    /**
31
+     * @param  string
32
+     * @param  mixed
33
+     * @return self
34
+     */
35
+    public function set($name, $value)
36
+    {
37
+        if ($value === NULL) {
38
+            return $this->remove($name);
39
+        }
40
+
41
+        $this->check(__METHOD__);
42
+        $_SESSION[$this->sessionKey][$name] = $value;
43
+
44
+        return $this;
45
+    }
46
+
47
+
48
+    /**
49
+     * @param  string
50
+     * @return mixed
51
+     */
52
+    public function get($name)
53
+    {
54
+        $this->check(__METHOD__);
55
+
56
+        return isset($_SESSION[$this->sessionKey][$name])
57
+            ? $_SESSION[$this->sessionKey][$name]
58
+            : NULL;
59
+    }
60
+
61
+
62
+    /**
63
+     * @param  string
64
+     * @return self
65
+     */
66
+    public function remove($name)
67
+    {
68
+        $this->check(__METHOD__);
69
+
70
+        unset($_SESSION[$this->sessionKey][$name]);
71
+
72
+        return $this;
73
+    }
74
+
75
+
76
+    /**
77
+     * @param  string
78
+     */
79
+    private function check($method)
80
+    {
81
+        if (!isset($_SESSION)) {
82
+            trigger_error("Start session before using $method().", E_USER_WARNING);
83
+        }
84
+    }
85 85
 
86 86
 }
Please login to merge, or discard this patch.
class/Github/Helpers.php 1 patch
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -13,89 +13,89 @@
 block discarded – undo
13 13
  */
14 14
 class Helpers
15 15
 {
16
-	private static $jsonMessages = [
17
-		JSON_ERROR_DEPTH => 'The maximum stack depth has been exceeded',
18
-		JSON_ERROR_STATE_MISMATCH => 'Syntax error, malformed JSON',
19
-		JSON_ERROR_CTRL_CHAR => 'Unexpected control character found',
20
-		JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON',
21
-		JSON_ERROR_UTF8 => 'Invalid UTF-8 sequence',
22
-	];
23
-
24
-
25
-	/** @var Http\IClient */
26
-	private static $client;
27
-
28
-
29
-	/**
30
-	 * @param  mixed
31
-	 * @return string
32
-	 *
33
-	 * @throws JsonException
34
-	 */
35
-	public static function jsonEncode($value)
36
-	{
37
-		if (PHP_VERSION_ID < 50500) {
38
-			set_error_handler(function($severity, $message) { // needed to receive 'recursion detected' error
39
-				restore_error_handler();
40
-				throw new JsonException($message);
41
-			});
42
-		}
43
-
44
-		$json = json_encode($value, JSON_UNESCAPED_UNICODE);
45
-
46
-		if (PHP_VERSION_ID < 50500) {
47
-			restore_error_handler();
48
-		}
49
-
50
-		if ($error = json_last_error()) {
51
-			$message = isset(static::$jsonMessages[$error])
52
-				? static::$jsonMessages[$error]
53
-				: (PHP_VERSION_ID >= 50500 ? json_last_error_msg() : 'Unknown error');
54
-
55
-			throw new JsonException($message, $error);
56
-		}
57
-
58
-		$json = str_replace(array("\xe2\x80\xa8", "\xe2\x80\xa9"), array('\u2028', '\u2029'), $json);
59
-		return $json;
60
-	}
61
-
62
-
63
-	/**
64
-	 * @param  mixed
65
-	 * @return string
66
-	 *
67
-	 * @throws JsonException
68
-	 */
69
-	public static function jsonDecode($json, $assoc = false)
70
-	{
71
-		$json = (string) $json;
72
-		if (!preg_match('##u', $json)) {
73
-			throw new JsonException('Invalid UTF-8 sequence', 5); // PECL JSON-C
74
-		}
75
-
76
-		$value = json_decode($json, $assoc, 512, (defined('JSON_C_VERSION') && PHP_INT_SIZE > 4) ? 0 : JSON_BIGINT_AS_STRING);
77
-
78
-		if ($value === NULL && $json !== '' && strcasecmp($json, 'null')) { // '' does not clear json_last_error()
79
-			$error = json_last_error();
80
-			throw new JsonException(isset(static::$jsonMessages[$error]) ? static::$jsonMessages[$error] : 'Unknown error', $error);
81
-		}
82
-		return $value;
83
-	}
84
-
85
-
86
-	/**
87
-	 * @param  bool
88
-	 * @return Http\IClient
89
-	 */
90
-	public static function createDefaultClient($newInstance = FALSE)
91
-	{
92
-		if (self::$client === NULL || $newInstance) {
93
-			self::$client = extension_loaded('curl')
94
-				? new Http\CurlClient
95
-				: new Http\StreamClient;
96
-		}
97
-
98
-		return self::$client;
99
-	}
16
+    private static $jsonMessages = [
17
+        JSON_ERROR_DEPTH => 'The maximum stack depth has been exceeded',
18
+        JSON_ERROR_STATE_MISMATCH => 'Syntax error, malformed JSON',
19
+        JSON_ERROR_CTRL_CHAR => 'Unexpected control character found',
20
+        JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON',
21
+        JSON_ERROR_UTF8 => 'Invalid UTF-8 sequence',
22
+    ];
23
+
24
+
25
+    /** @var Http\IClient */
26
+    private static $client;
27
+
28
+
29
+    /**
30
+     * @param  mixed
31
+     * @return string
32
+     *
33
+     * @throws JsonException
34
+     */
35
+    public static function jsonEncode($value)
36
+    {
37
+        if (PHP_VERSION_ID < 50500) {
38
+            set_error_handler(function($severity, $message) { // needed to receive 'recursion detected' error
39
+                restore_error_handler();
40
+                throw new JsonException($message);
41
+            });
42
+        }
43
+
44
+        $json = json_encode($value, JSON_UNESCAPED_UNICODE);
45
+
46
+        if (PHP_VERSION_ID < 50500) {
47
+            restore_error_handler();
48
+        }
49
+
50
+        if ($error = json_last_error()) {
51
+            $message = isset(static::$jsonMessages[$error])
52
+                ? static::$jsonMessages[$error]
53
+                : (PHP_VERSION_ID >= 50500 ? json_last_error_msg() : 'Unknown error');
54
+
55
+            throw new JsonException($message, $error);
56
+        }
57
+
58
+        $json = str_replace(array("\xe2\x80\xa8", "\xe2\x80\xa9"), array('\u2028', '\u2029'), $json);
59
+        return $json;
60
+    }
61
+
62
+
63
+    /**
64
+     * @param  mixed
65
+     * @return string
66
+     *
67
+     * @throws JsonException
68
+     */
69
+    public static function jsonDecode($json, $assoc = false)
70
+    {
71
+        $json = (string) $json;
72
+        if (!preg_match('##u', $json)) {
73
+            throw new JsonException('Invalid UTF-8 sequence', 5); // PECL JSON-C
74
+        }
75
+
76
+        $value = json_decode($json, $assoc, 512, (defined('JSON_C_VERSION') && PHP_INT_SIZE > 4) ? 0 : JSON_BIGINT_AS_STRING);
77
+
78
+        if ($value === NULL && $json !== '' && strcasecmp($json, 'null')) { // '' does not clear json_last_error()
79
+            $error = json_last_error();
80
+            throw new JsonException(isset(static::$jsonMessages[$error]) ? static::$jsonMessages[$error] : 'Unknown error', $error);
81
+        }
82
+        return $value;
83
+    }
84
+
85
+
86
+    /**
87
+     * @param  bool
88
+     * @return Http\IClient
89
+     */
90
+    public static function createDefaultClient($newInstance = FALSE)
91
+    {
92
+        if (self::$client === NULL || $newInstance) {
93
+            self::$client = extension_loaded('curl')
94
+                ? new Http\CurlClient
95
+                : new Http\StreamClient;
96
+        }
97
+
98
+        return self::$client;
99
+    }
100 100
 
101 101
 }
Please login to merge, or discard this patch.
class/RepositoriesHandler.php 1 patch
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -31,96 +31,96 @@
 block discarded – undo
31 31
  */
32 32
 class RepositoriesHandler extends \XoopsPersistableObjectHandler
33 33
 {
34
-	/**
35
-	 * Constructor
36
-	 *
37
-	 * @param \XoopsDatabase $db
38
-	 */
39
-	public function __construct(\XoopsDatabase $db)
40
-	{
41
-		parent::__construct($db, 'wggithub_repositories', Repositories::class, 'repo_id', 'repo_name');
42
-	}
43
-
44
-	/**
45
-	 * @param bool $isNew
46
-	 *
47
-	 * @return object
48
-	 */
49
-	public function create($isNew = true)
50
-	{
51
-		return parent::create($isNew);
52
-	}
53
-
54
-	/**
55
-	 * retrieve a field
56
-	 *
57
-	 * @param int $i field id
58
-	 * @param null fields
59
-	 * @return mixed reference to the {@link Get} object
60
-	 */
61
-	public function get($i = null, $fields = null)
62
-	{
63
-		return parent::get($i, $fields);
64
-	}
65
-
66
-	/**
67
-	 * get inserted id
68
-	 *
69
-	 * @param null
70
-	 * @return int reference to the {@link Get} object
71
-	 */
72
-	public function getInsertId()
73
-	{
74
-		return $this->db->getInsertId();
75
-	}
76
-
77
-	/**
78
-	 * Get Count Repositories in the database
79
-	 * @param int    $start
80
-	 * @param int    $limit
81
-	 * @param string $sort
82
-	 * @param string $order
83
-	 * @return int
84
-	 */
85
-	public function getCountRepositories($start = 0, $limit = 0, $sort = 'repo_id ASC, repo_name', $order = 'ASC')
86
-	{
87
-		$crCountRepositories = new \CriteriaCompo();
88
-		$crCountRepositories = $this->getRepositoriesCriteria($crCountRepositories, $start, $limit, $sort, $order);
89
-		return $this->getCount($crCountRepositories);
90
-	}
91
-
92
-	/**
93
-	 * Get All Repositories in the database
94
-	 * @param int    $start
95
-	 * @param int    $limit
96
-	 * @param string $sort
97
-	 * @param string $order
98
-	 * @return array
99
-	 */
100
-	public function getAllRepositories($start = 0, $limit = 0, $sort = 'repo_id ASC, repo_name', $order = 'ASC')
101
-	{
102
-		$crAllRepositories = new \CriteriaCompo();
103
-		$crAllRepositories = $this->getRepositoriesCriteria($crAllRepositories, $start, $limit, $sort, $order);
104
-		return $this->getAll($crAllRepositories);
105
-	}
106
-
107
-	/**
108
-	 * Get Criteria Repositories
109
-	 * @param        $crRepositories
110
-	 * @param int    $start
111
-	 * @param int    $limit
112
-	 * @param string $sort
113
-	 * @param string $order
114
-	 * @return int
115
-	 */
116
-	private function getRepositoriesCriteria($crRepositories, $start, $limit, $sort, $order)
117
-	{
118
-		$crRepositories->setStart($start);
119
-		$crRepositories->setLimit($limit);
120
-		$crRepositories->setSort($sort);
121
-		$crRepositories->setOrder($order);
122
-		return $crRepositories;
123
-	}
34
+    /**
35
+     * Constructor
36
+     *
37
+     * @param \XoopsDatabase $db
38
+     */
39
+    public function __construct(\XoopsDatabase $db)
40
+    {
41
+        parent::__construct($db, 'wggithub_repositories', Repositories::class, 'repo_id', 'repo_name');
42
+    }
43
+
44
+    /**
45
+     * @param bool $isNew
46
+     *
47
+     * @return object
48
+     */
49
+    public function create($isNew = true)
50
+    {
51
+        return parent::create($isNew);
52
+    }
53
+
54
+    /**
55
+     * retrieve a field
56
+     *
57
+     * @param int $i field id
58
+     * @param null fields
59
+     * @return mixed reference to the {@link Get} object
60
+     */
61
+    public function get($i = null, $fields = null)
62
+    {
63
+        return parent::get($i, $fields);
64
+    }
65
+
66
+    /**
67
+     * get inserted id
68
+     *
69
+     * @param null
70
+     * @return int reference to the {@link Get} object
71
+     */
72
+    public function getInsertId()
73
+    {
74
+        return $this->db->getInsertId();
75
+    }
76
+
77
+    /**
78
+     * Get Count Repositories in the database
79
+     * @param int    $start
80
+     * @param int    $limit
81
+     * @param string $sort
82
+     * @param string $order
83
+     * @return int
84
+     */
85
+    public function getCountRepositories($start = 0, $limit = 0, $sort = 'repo_id ASC, repo_name', $order = 'ASC')
86
+    {
87
+        $crCountRepositories = new \CriteriaCompo();
88
+        $crCountRepositories = $this->getRepositoriesCriteria($crCountRepositories, $start, $limit, $sort, $order);
89
+        return $this->getCount($crCountRepositories);
90
+    }
91
+
92
+    /**
93
+     * Get All Repositories in the database
94
+     * @param int    $start
95
+     * @param int    $limit
96
+     * @param string $sort
97
+     * @param string $order
98
+     * @return array
99
+     */
100
+    public function getAllRepositories($start = 0, $limit = 0, $sort = 'repo_id ASC, repo_name', $order = 'ASC')
101
+    {
102
+        $crAllRepositories = new \CriteriaCompo();
103
+        $crAllRepositories = $this->getRepositoriesCriteria($crAllRepositories, $start, $limit, $sort, $order);
104
+        return $this->getAll($crAllRepositories);
105
+    }
106
+
107
+    /**
108
+     * Get Criteria Repositories
109
+     * @param        $crRepositories
110
+     * @param int    $start
111
+     * @param int    $limit
112
+     * @param string $sort
113
+     * @param string $order
114
+     * @return int
115
+     */
116
+    private function getRepositoriesCriteria($crRepositories, $start, $limit, $sort, $order)
117
+    {
118
+        $crRepositories->setStart($start);
119
+        $crRepositories->setLimit($limit);
120
+        $crRepositories->setSort($sort);
121
+        $crRepositories->setOrder($order);
122
+        return $crRepositories;
123
+    }
124 124
 
125 125
     /**
126 126
      * Update table repositories
Please login to merge, or discard this patch.
class/Constants.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
  */
29 29
 interface Constants
30 30
 {
31
-	// Constants for tables
31
+    // Constants for tables
32 32
     public const TABLE_SETTINGS = 0;
33 33
     public const TABLE_REPOSITORIES = 1;
34 34
     public const TABLE_DIRECTORIES = 2;
@@ -39,17 +39,17 @@  discard block
 block discarded – undo
39 39
     public const DIRECTORY_TYPE_USER = 1;
40 40
     public const DIRECTORY_TYPE_ORG  = 2;
41 41
 
42
-	// Constants for status
43
-	public const STATUS_NONE     = 0;
42
+    // Constants for status
43
+    public const STATUS_NONE     = 0;
44 44
     public const STATUS_NEW      = 1;
45 45
     public const STATUS_UPDATED  = 2;
46
-	public const STATUS_UPTODATE = 3;
46
+    public const STATUS_UPTODATE = 3;
47 47
 
48
-	// Constants for permissions
49
-	public const PERM_GLOBAL_NONE   = 0;
50
-	public const PERM_GLOBAL_VIEW   = 1;
51
-	public const PERM_GLOBAL_READ   = 2;
52
-	public const PERM_README_UPDATE = 3;
48
+    // Constants for permissions
49
+    public const PERM_GLOBAL_NONE   = 0;
50
+    public const PERM_GLOBAL_VIEW   = 1;
51
+    public const PERM_GLOBAL_READ   = 2;
52
+    public const PERM_README_UPDATE = 3;
53 53
 
54 54
     // Constants for log type
55 55
     public const LOG_TYPE_NONE  = 0;
Please login to merge, or discard this patch.
class/LogsHandler.php 1 patch
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -31,96 +31,96 @@
 block discarded – undo
31 31
  */
32 32
 class LogsHandler extends \XoopsPersistableObjectHandler
33 33
 {
34
-	/**
35
-	 * Constructor
36
-	 *
37
-	 * @param \XoopsDatabase $db
38
-	 */
39
-	public function __construct(\XoopsDatabase $db)
40
-	{
41
-		parent::__construct($db, 'wggithub_logs', Logs::class, 'log_id', 'log_detail');
42
-	}
43
-
44
-	/**
45
-	 * @param bool $isNew
46
-	 *
47
-	 * @return object
48
-	 */
49
-	public function create($isNew = true)
50
-	{
51
-		return parent::create($isNew);
52
-	}
53
-
54
-	/**
55
-	 * retrieve a field
56
-	 *
57
-	 * @param int $i field id
58
-	 * @param null fields
59
-	 * @return mixed reference to the {@link Get} object
60
-	 */
61
-	public function get($i = null, $fields = null)
62
-	{
63
-		return parent::get($i, $fields);
64
-	}
65
-
66
-	/**
67
-	 * get inserted id
68
-	 *
69
-	 * @param null
70
-	 * @return int reference to the {@link Get} object
71
-	 */
72
-	public function getInsertId()
73
-	{
74
-		return $this->db->getInsertId();
75
-	}
76
-
77
-	/**
78
-	 * Get Count Logs in the database
79
-	 * @param int    $start
80
-	 * @param int    $limit
81
-	 * @param string $sort
82
-	 * @param string $order
83
-	 * @return int
84
-	 */
85
-	public function getCountLogs($start = 0, $limit = 0, $sort = 'log_id', $order = 'ASC')
86
-	{
87
-		$crCountLogs = new \CriteriaCompo();
88
-		$crCountLogs = $this->getLogsCriteria($crCountLogs, $start, $limit, $sort, $order);
89
-		return $this->getCount($crCountLogs);
90
-	}
91
-
92
-	/**
93
-	 * Get All Logs in the database
94
-	 * @param int    $start
95
-	 * @param int    $limit
96
-	 * @param string $sort
97
-	 * @param string $order
98
-	 * @return array
99
-	 */
100
-	public function getAllLogs($start = 0, $limit = 0, $sort = 'log_id', $order = 'ASC')
101
-	{
102
-		$crAllLogs = new \CriteriaCompo();
103
-		$crAllLogs = $this->getLogsCriteria($crAllLogs, $start, $limit, $sort, $order);
104
-		return $this->getAll($crAllLogs);
105
-	}
106
-
107
-	/**
108
-	 * Get Criteria Logs
109
-	 * @param        $crLogs
110
-	 * @param int    $start
111
-	 * @param int    $limit
112
-	 * @param string $sort
113
-	 * @param string $order
114
-	 * @return int
115
-	 */
116
-	private function getLogsCriteria($crLogs, $start, $limit, $sort, $order)
117
-	{
118
-		$crLogs->setStart($start);
119
-		$crLogs->setLimit($limit);
120
-		$crLogs->setSort($sort);
121
-		$crLogs->setOrder($order);
122
-		return $crLogs;
123
-	}
34
+    /**
35
+     * Constructor
36
+     *
37
+     * @param \XoopsDatabase $db
38
+     */
39
+    public function __construct(\XoopsDatabase $db)
40
+    {
41
+        parent::__construct($db, 'wggithub_logs', Logs::class, 'log_id', 'log_detail');
42
+    }
43
+
44
+    /**
45
+     * @param bool $isNew
46
+     *
47
+     * @return object
48
+     */
49
+    public function create($isNew = true)
50
+    {
51
+        return parent::create($isNew);
52
+    }
53
+
54
+    /**
55
+     * retrieve a field
56
+     *
57
+     * @param int $i field id
58
+     * @param null fields
59
+     * @return mixed reference to the {@link Get} object
60
+     */
61
+    public function get($i = null, $fields = null)
62
+    {
63
+        return parent::get($i, $fields);
64
+    }
65
+
66
+    /**
67
+     * get inserted id
68
+     *
69
+     * @param null
70
+     * @return int reference to the {@link Get} object
71
+     */
72
+    public function getInsertId()
73
+    {
74
+        return $this->db->getInsertId();
75
+    }
76
+
77
+    /**
78
+     * Get Count Logs in the database
79
+     * @param int    $start
80
+     * @param int    $limit
81
+     * @param string $sort
82
+     * @param string $order
83
+     * @return int
84
+     */
85
+    public function getCountLogs($start = 0, $limit = 0, $sort = 'log_id', $order = 'ASC')
86
+    {
87
+        $crCountLogs = new \CriteriaCompo();
88
+        $crCountLogs = $this->getLogsCriteria($crCountLogs, $start, $limit, $sort, $order);
89
+        return $this->getCount($crCountLogs);
90
+    }
91
+
92
+    /**
93
+     * Get All Logs in the database
94
+     * @param int    $start
95
+     * @param int    $limit
96
+     * @param string $sort
97
+     * @param string $order
98
+     * @return array
99
+     */
100
+    public function getAllLogs($start = 0, $limit = 0, $sort = 'log_id', $order = 'ASC')
101
+    {
102
+        $crAllLogs = new \CriteriaCompo();
103
+        $crAllLogs = $this->getLogsCriteria($crAllLogs, $start, $limit, $sort, $order);
104
+        return $this->getAll($crAllLogs);
105
+    }
106
+
107
+    /**
108
+     * Get Criteria Logs
109
+     * @param        $crLogs
110
+     * @param int    $start
111
+     * @param int    $limit
112
+     * @param string $sort
113
+     * @param string $order
114
+     * @return int
115
+     */
116
+    private function getLogsCriteria($crLogs, $start, $limit, $sort, $order)
117
+    {
118
+        $crLogs->setStart($start);
119
+        $crLogs->setLimit($limit);
120
+        $crLogs->setSort($sort);
121
+        $crLogs->setOrder($order);
122
+        return $crLogs;
123
+    }
124 124
 
125 125
     /**
126 126
      * Update table requests
Please login to merge, or discard this patch.
class/Github/exceptions.php 1 patch
Indentation   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -8,169 +8,169 @@
 block discarded – undo
8 8
  */
9 9
 
10 10
 namespace XoopsModules\Wggithub\Github {
11
-	/**
12
-	 * Marker interface.
13
-	 */
14
-	interface IException
15
-	{}
11
+    /**
12
+     * Marker interface.
13
+     */
14
+    interface IException
15
+    {}
16 16
 
17 17
 
18
-	/**
19
-	 * Wrong algorithm. API is used in wrong way. Application code should be changed.
20
-	 */
21
-	class LogicException extends \LogicException implements IException
22
-	{}
18
+    /**
19
+     * Wrong algorithm. API is used in wrong way. Application code should be changed.
20
+     */
21
+    class LogicException extends \LogicException implements IException
22
+    {}
23 23
 
24 24
 
25
-	/**
26
-	 * Substitution is used in URL path but corresponding parameter is missing.
27
-	 */
28
-	class MissingParameterException extends LogicException
29
-	{}
25
+    /**
26
+     * Substitution is used in URL path but corresponding parameter is missing.
27
+     */
28
+    class MissingParameterException extends LogicException
29
+    {}
30 30
 
31 31
 
32
-	/**
33
-	 * Unpredictable situation occurred.
34
-	 */
35
-	abstract class RuntimeException extends \RuntimeException implements IException
36
-	{}
32
+    /**
33
+     * Unpredictable situation occurred.
34
+     */
35
+    abstract class RuntimeException extends \RuntimeException implements IException
36
+    {}
37 37
 
38 38
 
39
-	/**
40
-	 * Github API returned a non-success HTTP code or data are somehow wrong. See all following descendants.
41
-	 *
42
-	 * @see Api::decode()
43
-	 * @see https://developer.github.com/v3/#client-errors
44
-	 */
45
-	abstract class ApiException extends RuntimeException
46
-	{
47
-		/** @var Http\Response|NULL */
48
-		private $response;
39
+    /**
40
+     * Github API returned a non-success HTTP code or data are somehow wrong. See all following descendants.
41
+     *
42
+     * @see Api::decode()
43
+     * @see https://developer.github.com/v3/#client-errors
44
+     */
45
+    abstract class ApiException extends RuntimeException
46
+    {
47
+        /** @var Http\Response|NULL */
48
+        private $response;
49 49
 
50 50
 
51
-		/**
52
-		 * @param string
53
-		 * @param int
54
-		 */
55
-		public function __construct($message = '', $code = 0, \Exception $previous = NULL, Http\Response $response = NULL)
56
-		{
57
-			parent::__construct($message, $code, $previous);
58
-			$this->response = clone $response;
59
-		}
51
+        /**
52
+         * @param string
53
+         * @param int
54
+         */
55
+        public function __construct($message = '', $code = 0, \Exception $previous = NULL, Http\Response $response = NULL)
56
+        {
57
+            parent::__construct($message, $code, $previous);
58
+            $this->response = clone $response;
59
+        }
60 60
 
61 61
 
62
-		/**
63
-		 * @return Http\Response|NULL
64
-		 */
65
-		final public function getResponse()
66
-		{
67
-			return $this->response;
68
-		}
62
+        /**
63
+         * @return Http\Response|NULL
64
+         */
65
+        final public function getResponse()
66
+        {
67
+            return $this->response;
68
+        }
69 69
 
70
-	}
70
+    }
71 71
 
72 72
 
73
-	/**
74
-	 * Invalid credentials (e.g. revoked token).
75
-	 */
76
-	class UnauthorizedException extends ApiException
77
-	{}
73
+    /**
74
+     * Invalid credentials (e.g. revoked token).
75
+     */
76
+    class UnauthorizedException extends ApiException
77
+    {}
78 78
 
79 79
 
80
-	/**
81
-	 * Invalid JSON sent to Github API.
82
-	 */
83
-	class BadRequestException extends ApiException
84
-	{}
80
+    /**
81
+     * Invalid JSON sent to Github API.
82
+     */
83
+    class BadRequestException extends ApiException
84
+    {}
85 85
 
86 86
 
87
-	/**
88
-	 * Invalid structure sent to Github API (e.g. some required fields are missing).
89
-	 */
90
-	class UnprocessableEntityException extends ApiException
91
-	{}
87
+    /**
88
+     * Invalid structure sent to Github API (e.g. some required fields are missing).
89
+     */
90
+    class UnprocessableEntityException extends ApiException
91
+    {}
92 92
 
93 93
 
94
-	/**
95
-	 * Access denied.
96
-	 * @see https://developer.github.com/v3/#authentication
97
-	 */
98
-	class ForbiddenException extends ApiException
99
-	{}
94
+    /**
95
+     * Access denied.
96
+     * @see https://developer.github.com/v3/#authentication
97
+     */
98
+    class ForbiddenException extends ApiException
99
+    {}
100 100
 
101 101
 
102
-	/**
103
-	 * Rate limit exceed.
104
-	 * @see https://developer.github.com/v3/#rate-limiting
105
-	 */
106
-	class RateLimitExceedException extends ForbiddenException
107
-	{}
102
+    /**
103
+     * Rate limit exceed.
104
+     * @see https://developer.github.com/v3/#rate-limiting
105
+     */
106
+    class RateLimitExceedException extends ForbiddenException
107
+    {}
108 108
 
109 109
 
110
-	/**
111
-	 * Resource not found.
112
-	 * @see https://developer.github.com/v3/#authentication
113
-	 */
114
-	class NotFoundException extends ApiException
115
-	{}
110
+    /**
111
+     * Resource not found.
112
+     * @see https://developer.github.com/v3/#authentication
113
+     */
114
+    class NotFoundException extends ApiException
115
+    {}
116 116
 
117 117
 
118
-	/**
119
-	 * Response cannot be classified.
120
-	 */
121
-	class UnexpectedResponseException extends ApiException
122
-	{}
118
+    /**
119
+     * Response cannot be classified.
120
+     */
121
+    class UnexpectedResponseException extends ApiException
122
+    {}
123 123
 
124 124
 
125
-	/**
126
-	 * Response from Github is somehow wrong (e.g. invalid JSON decoding).
127
-	 */
128
-	class InvalidResponseException extends ApiException
129
-	{}
125
+    /**
126
+     * Response from Github is somehow wrong (e.g. invalid JSON decoding).
127
+     */
128
+    class InvalidResponseException extends ApiException
129
+    {}
130 130
 
131 131
 
132
-	/**
133
-	 * JSON cannot be decoded, or value cannot be encoded to JSON.
134
-	 */
135
-	class JsonException extends RuntimeException
136
-	{
137
-	}
132
+    /**
133
+     * JSON cannot be decoded, or value cannot be encoded to JSON.
134
+     */
135
+    class JsonException extends RuntimeException
136
+    {
137
+    }
138 138
 
139 139
 }
140 140
 
141 141
 
142 142
 namespace Milo\Github\Http {
143
-	use Milo\Github;
143
+    use Milo\Github;
144 144
 
145 145
 
146
-	/**
147
-	 * HTTP response is somehow wrong and cannot be processed.
148
-	 */
149
-	class BadResponseException extends Github\RuntimeException
150
-	{}
146
+    /**
147
+     * HTTP response is somehow wrong and cannot be processed.
148
+     */
149
+    class BadResponseException extends Github\RuntimeException
150
+    {}
151 151
 
152 152
 }
153 153
 
154 154
 
155 155
 namespace Milo\Github\OAuth {
156
-	use Milo\Github;
156
+    use Milo\Github;
157 157
 
158
-	/**
159
-	 * Something fails during the token obtaining.
160
-	 */
161
-	class LoginException extends Github\RuntimeException
162
-	{}
158
+    /**
159
+     * Something fails during the token obtaining.
160
+     */
161
+    class LoginException extends Github\RuntimeException
162
+    {}
163 163
 
164 164
 }
165 165
 
166 166
 
167 167
 namespace Milo\Github\Storages {
168
-	use Milo\Github;
168
+    use Milo\Github;
169 169
 
170
-	/**
171
-	 * Directory is missing and/or cannot be created.
172
-	 */
173
-	class MissingDirectoryException extends Github\RuntimeException
174
-	{}
170
+    /**
171
+     * Directory is missing and/or cannot be created.
172
+     */
173
+    class MissingDirectoryException extends Github\RuntimeException
174
+    {}
175 175
 
176 176
 }
Please login to merge, or discard this patch.