GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Branch master (3eac19)
by Gabriel
05:37 queued 18s
created
src/Helpers/view/Messages.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
     /**
63 63
      * Singleton
64 64
      *
65
-     * @return Nip_Helper_View_Errors
65
+     * @return Nip_Helper_View_Messages
66 66
      */
67 67
     static public function instance()
68 68
     {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
         
39 39
         if (count($items)) {
40 40
             if ($wrap) {
41
-                $return .= '<div class="'.($type ? $this->_cssClass[$type] : '' ).'">';
41
+                $return .= '<div class="' . ($type ? $this->_cssClass[$type] : '') . '">';
42 42
                 if (count($items) > 1) {
43 43
                     $return .= "<ul>";
44 44
                 }
Please login to merge, or discard this patch.
src/I18n.php 3 patches
Doc Comments   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 
16 16
 	/**
17 17
 	 * Sets the translation backend
18
-	 * @param Nip_I18n_Abstract $backend
18
+	 * @param Nip_I18n_Backend_Abstract $backend
19 19
 	 * @return Nip_I18n
20 20
 	 */
21 21
 	public function setBackend(Nip_I18n_Backend_Abstract $backend)
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 
67 67
 	/**
68 68
 	 * gets the default language to be used when translating
69
-	 * @return string $language
69
+	 * @return boolean $language
70 70
 	 */
71 71
 	public function getDefaultLanguage()
72 72
 	{
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 * Checks SESSION, GET and Nip_Request and selects requested language
87 87
 	 * If language not requested, falls back to default
88 88
 	 *
89
-	 * @return string
89
+	 * @return boolean
90 90
 	 */
91 91
 	public function getLanguage()
92 92
 	{
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 *
153 153
 	 * @param string $slug
154 154
 	 * @param string $language
155
-	 * @return string
155
+	 * @return boolean
156 156
 	 */
157 157
 	public function hasTranslation($slug = false, $params = array(), $language = false)
158 158
 	{
@@ -196,12 +196,19 @@  discard block
 block discarded – undo
196 196
 }
197 197
 
198 198
 if (!function_exists("__")) {
199
+
200
+	/**
201
+	 * @param string $slug
202
+	 */
199 203
 	function __($slug, $params = array(), $language = false)
200 204
 	{
201 205
 		return Nip_I18n::instance()->translate($slug, $params, $language);
202 206
 	}
203 207
 }
204 208
 
209
+/**
210
+ * @param string $slug
211
+ */
205 212
 function nip__($slug, $params = array(), $language = false)
206 213
 {
207 214
     return Nip_I18n::instance()->translate($slug, $params, $language);
Please login to merge, or discard this patch.
Indentation   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -7,23 +7,23 @@  discard block
 block discarded – undo
7 7
         'en' => 'en_US'
8 8
         );
9 9
 
10
-	protected $_backend;
11
-	protected $_request;
12
-
13
-	public $defaultLanguage = false;
14
-	public $selectedLanguage = false;
15
-
16
-	/**
17
-	 * Sets the translation backend
18
-	 * @param Nip_I18n_Abstract $backend
19
-	 * @return Nip_I18n
20
-	 */
21
-	public function setBackend(Nip_I18n_Backend_Abstract $backend)
22
-	{
23
-		$this->_backend = $backend;
10
+    protected $_backend;
11
+    protected $_request;
12
+
13
+    public $defaultLanguage = false;
14
+    public $selectedLanguage = false;
15
+
16
+    /**
17
+     * Sets the translation backend
18
+     * @param Nip_I18n_Abstract $backend
19
+     * @return Nip_I18n
20
+     */
21
+    public function setBackend(Nip_I18n_Backend_Abstract $backend)
22
+    {
23
+        $this->_backend = $backend;
24 24
         $this->_backend->setI18n($this);
25
-		return $this;
26
-	}
25
+        return $this;
26
+    }
27 27
 
28 28
     /**
29 29
      * @return Nip_I18n_Backend_Abstract
@@ -33,63 +33,63 @@  discard block
 block discarded – undo
33 33
         return $this->_backend;
34 34
     }
35 35
 
36
-	/**
37
-	 * Selects a language to be used when translating
38
-	 *
39
-	 * @param string $language
40
-	 * @return Nip_I18n
41
-	 */
42
-	public function setLanguage($language)
43
-	{
44
-		$this->selectedLanguage = $language;
45
-		$_SESSION['language'] = $language;
46
-
47
-		$code = $this->_languageCodes[$language] ? $this->_languageCodes[$language] : $language . "_" . strtoupper($language);
48
-
49
-		putenv('LC_ALL=' . $language);
50
-		setlocale(LC_ALL, $language);
51
-
52
-		return $this;
53
-	}
54
-
55
-	/**
56
-	 * Sets the default language to be used when translating
57
-	 *
58
-	 * @param string $language
59
-	 * @return Nip_I18n
60
-	 */
61
-	public function setDefaultLanguage($language)
62
-	{
63
-		$this->defaultLanguage = $language;
64
-		return $this;
65
-	}
66
-
67
-	/**
68
-	 * gets the default language to be used when translating
69
-	 * @return string $language
70
-	 */
71
-	public function getDefaultLanguage()
72
-	{
36
+    /**
37
+     * Selects a language to be used when translating
38
+     *
39
+     * @param string $language
40
+     * @return Nip_I18n
41
+     */
42
+    public function setLanguage($language)
43
+    {
44
+        $this->selectedLanguage = $language;
45
+        $_SESSION['language'] = $language;
46
+
47
+        $code = $this->_languageCodes[$language] ? $this->_languageCodes[$language] : $language . "_" . strtoupper($language);
48
+
49
+        putenv('LC_ALL=' . $language);
50
+        setlocale(LC_ALL, $language);
51
+
52
+        return $this;
53
+    }
54
+
55
+    /**
56
+     * Sets the default language to be used when translating
57
+     *
58
+     * @param string $language
59
+     * @return Nip_I18n
60
+     */
61
+    public function setDefaultLanguage($language)
62
+    {
63
+        $this->defaultLanguage = $language;
64
+        return $this;
65
+    }
66
+
67
+    /**
68
+     * gets the default language to be used when translating
69
+     * @return string $language
70
+     */
71
+    public function getDefaultLanguage()
72
+    {
73 73
         if (!$this->defaultLanguage) {
74 74
             $this->setDefaultLanguage(substr(setlocale(LC_ALL, 0), 0, 2));
75 75
         }
76
-		return $this->defaultLanguage;
77
-	}
78
-
79
-
80
-	public function getLanguages()
81
-	{
82
-		return $this->_backend->getLanguages();
83
-	}
84
-
85
-	/**
86
-	 * Checks SESSION, GET and Nip_Request and selects requested language
87
-	 * If language not requested, falls back to default
88
-	 *
89
-	 * @return string
90
-	 */
91
-	public function getLanguage()
92
-	{
76
+        return $this->defaultLanguage;
77
+    }
78
+
79
+
80
+    public function getLanguages()
81
+    {
82
+        return $this->_backend->getLanguages();
83
+    }
84
+
85
+    /**
86
+     * Checks SESSION, GET and Nip_Request and selects requested language
87
+     * If language not requested, falls back to default
88
+     *
89
+     * @return string
90
+     */
91
+    public function getLanguage()
92
+    {
93 93
         if (!$this->selectedLanguage) {
94 94
             if (isset($_SESSION['language'])) {
95 95
                 $language = $_SESSION['language'];
@@ -111,95 +111,95 @@  discard block
 block discarded – undo
111 111
             }
112 112
         }
113 113
 
114
-		return $this->selectedLanguage;
115
-	}
114
+        return $this->selectedLanguage;
115
+    }
116 116
 
117
-	public function changeLangURL($lang)
118
-	{
117
+    public function changeLangURL($lang)
118
+    {
119 119
         $newURL = str_replace('language='.$this->getLanguage(), '', CURRENT_URL);
120 120
         $newURL = $newURL . (strpos($newURL, '?') == false ? '?' : '&') .'language='.$lang;
121
-		return $newURL;
122
-	}  
121
+        return $newURL;
122
+    }  
123 123
     
124
-	/**
125
-	 * Returns translation of $slug in given or selected $language
126
-	 *
127
-	 * @param string $slug
128
-	 * @param string $language
129
-	 * @return string
130
-	 */
131
-	public function translate($slug = false, $params = array(), $language = false)	{
124
+    /**
125
+     * Returns translation of $slug in given or selected $language
126
+     *
127
+     * @param string $slug
128
+     * @param string $language
129
+     * @return string
130
+     */
131
+    public function translate($slug = false, $params = array(), $language = false)	{
132 132
         
133
-		if (!$language) {
134
-			$language = $this->getLanguage();
135
-		}
136
-
137
-		$return = $this->_backend->translate($slug, $language);
138
-
139
-		if ($return) {
140
-			if ($params) {
141
-				foreach ($params as $key => $value) {
142
-					$return = str_replace("#{" . $key . "}", $value, $return);
143
-				}
144
-			}
145
-		}
146
-
147
-		return $return;
148
-	}
149
-
150
-	/**
151
-	 * Returns translation of $slug in given or selected $language
152
-	 *
153
-	 * @param string $slug
154
-	 * @param string $language
155
-	 * @return string
156
-	 */
157
-	public function hasTranslation($slug = false, $params = array(), $language = false)
158
-	{
159
-		if (!$language) {
160
-			$language = $this->getLanguage();
161
-		}
162
-
163
-		return $this->_backend->hasTranslation($slug, $language);;
164
-	}
165
-
166
-	/**
167
-	 * @return mixed
168
-	 */
169
-	public function getRequest()
170
-	{
171
-		return $this->_request;
172
-	}
173
-
174
-	/**
175
-	 * @param mixed $request
176
-	 */
177
-	public function setRequest($request)
178
-	{
179
-		$this->_request = $request;
180
-	}
181
-
182
-	/**
183
-	 * Singleton pattern
184
-	 *
185
-	 * @return Nip_I18n
186
-	 */
187
-	static public function instance()
188
-	{
189
-		static $instance;
190
-		if (!($instance instanceof self)) {
191
-			$instance = new self();
192
-		}
193
-		return $instance;
194
-	}
133
+        if (!$language) {
134
+            $language = $this->getLanguage();
135
+        }
136
+
137
+        $return = $this->_backend->translate($slug, $language);
138
+
139
+        if ($return) {
140
+            if ($params) {
141
+                foreach ($params as $key => $value) {
142
+                    $return = str_replace("#{" . $key . "}", $value, $return);
143
+                }
144
+            }
145
+        }
146
+
147
+        return $return;
148
+    }
149
+
150
+    /**
151
+     * Returns translation of $slug in given or selected $language
152
+     *
153
+     * @param string $slug
154
+     * @param string $language
155
+     * @return string
156
+     */
157
+    public function hasTranslation($slug = false, $params = array(), $language = false)
158
+    {
159
+        if (!$language) {
160
+            $language = $this->getLanguage();
161
+        }
162
+
163
+        return $this->_backend->hasTranslation($slug, $language);;
164
+    }
165
+
166
+    /**
167
+     * @return mixed
168
+     */
169
+    public function getRequest()
170
+    {
171
+        return $this->_request;
172
+    }
173
+
174
+    /**
175
+     * @param mixed $request
176
+     */
177
+    public function setRequest($request)
178
+    {
179
+        $this->_request = $request;
180
+    }
181
+
182
+    /**
183
+     * Singleton pattern
184
+     *
185
+     * @return Nip_I18n
186
+     */
187
+    static public function instance()
188
+    {
189
+        static $instance;
190
+        if (!($instance instanceof self)) {
191
+            $instance = new self();
192
+        }
193
+        return $instance;
194
+    }
195 195
 
196 196
 }
197 197
 
198 198
 if (!function_exists("__")) {
199
-	function __($slug, $params = array(), $language = false)
200
-	{
201
-		return Nip_I18n::instance()->translate($slug, $params, $language);
202
-	}
199
+    function __($slug, $params = array(), $language = false)
200
+    {
201
+        return Nip_I18n::instance()->translate($slug, $params, $language);
202
+    }
203 203
 }
204 204
 
205 205
 function nip__($slug, $params = array(), $language = false)
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -116,8 +116,8 @@  discard block
 block discarded – undo
116 116
 
117 117
 	public function changeLangURL($lang)
118 118
 	{
119
-        $newURL = str_replace('language='.$this->getLanguage(), '', CURRENT_URL);
120
-        $newURL = $newURL . (strpos($newURL, '?') == false ? '?' : '&') .'language='.$lang;
119
+        $newURL = str_replace('language=' . $this->getLanguage(), '', CURRENT_URL);
120
+        $newURL = $newURL . (strpos($newURL, '?') == false ? '?' : '&') . 'language=' . $lang;
121 121
 		return $newURL;
122 122
 	}  
123 123
     
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @param string $language
129 129
 	 * @return string
130 130
 	 */
131
-	public function translate($slug = false, $params = array(), $language = false)	{
131
+	public function translate($slug = false, $params = array(), $language = false) {
132 132
         
133 133
 		if (!$language) {
134 134
 			$language = $this->getLanguage();
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 			$language = $this->getLanguage();
161 161
 		}
162 162
 
163
-		return $this->_backend->hasTranslation($slug, $language);;
163
+		return $this->_backend->hasTranslation($slug, $language); ;
164 164
 	}
165 165
 
166 166
 	/**
Please login to merge, or discard this patch.
src/i18n/backend/Abstract.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -4,6 +4,9 @@  discard block
 block discarded – undo
4 4
     protected $_i18n;
5 5
     protected $languages;
6 6
 
7
+    /**
8
+     * @param Nip_I18n $i18n
9
+     */
7 10
     public function setI18n($i18n)
8 11
     {
9 12
         $this->_i18n = $i18n;
@@ -38,6 +41,9 @@  discard block
 block discarded – undo
38 41
         return $slug;
39 42
     }
40 43
 
44
+    /**
45
+     * @param false|string $slug
46
+     */
41 47
     public function hasTranslation($slug, $language = false)
42 48
     {
43 49
         $return = $this->_translate($slug, $language);
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
             return $return;
35 35
         }
36 36
 
37
-        trigger_error("Dictionary entry for [". $slug ."] does not exist.", E_USER_WARNING);
37
+        trigger_error("Dictionary entry for [" . $slug . "] does not exist.", E_USER_WARNING);
38 38
         return $slug;
39 39
     }
40 40
 
Please login to merge, or discard this patch.
src/i18n/backend/Database.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
      * Adds a language to the dictionary
37 37
      *
38 38
      * @param string $language
39
-     * @return Nip_I18n
39
+     * @return Nip_I18n_Backend_Database
40 40
      */
41 41
     public function addLanguage($language) {
42 42
         $this->languages[] = $language;
Please login to merge, or discard this patch.
src/i18n/backend/File.php 2 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
      *
20 20
      * @param string $language
21 21
      * @param string $file Path to file containing translations
22
-     * @return Nip_I18n
22
+     * @return Nip_I18n_Backend_File
23 23
      */
24 24
     public function addLanguage($language, $file)
25 25
     {
@@ -47,6 +47,9 @@  discard block
 block discarded – undo
47 47
         return $this;
48 48
     }
49 49
 
50
+    /**
51
+     * @param string $language
52
+     */
50 53
     protected function parseFile($file, $language)
51 54
     {
52 55
         if (file_exists($file)) {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,12 +36,12 @@
 block discarded – undo
36 36
                 }
37 37
             }
38 38
             ob_end_clean();
39
-        } elseif (is_file ($file)) {
39
+        } elseif (is_file($file)) {
40 40
             ob_start();
41 41
             $this->parseFile($file, $language);
42 42
             ob_end_clean();
43 43
         } else {
44
-            trigger_error("Language file [".$file."] does not exist", E_USER_ERROR);
44
+            trigger_error("Language file [" . $file . "] does not exist", E_USER_ERROR);
45 45
         }
46 46
 
47 47
         return $this;
Please login to merge, or discard this patch.
src/i18n/backend/Po.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
 	 * Sets and binds the text domain
10 10
 	 *
11 11
 	 * @param string $path
12
-	 * @return Nip_I18n_Po
12
+	 * @return Nip_I18n_Backend_Po
13 13
 	 */
14 14
 	public function setPath($path)
15 15
 	{
Please login to merge, or discard this patch.
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -3,36 +3,36 @@
 block discarded – undo
3 3
 class Nip_I18n_Backend_Po extends Nip_I18n_Backend_Abstract
4 4
 {
5 5
 
6
-	protected $_path;
6
+    protected $_path;
7 7
 
8
-	/**
9
-	 * Sets and binds the text domain
10
-	 *
11
-	 * @param string $path
12
-	 * @return Nip_I18n_Po
13
-	 */
14
-	public function setPath($path)
15
-	{
16
-		$this->_path = $path;
8
+    /**
9
+     * Sets and binds the text domain
10
+     *
11
+     * @param string $path
12
+     * @return Nip_I18n_Po
13
+     */
14
+    public function setPath($path)
15
+    {
16
+        $this->_path = $path;
17 17
 
18
-		bindtextdomain("messages", $this->_path);
18
+        bindtextdomain("messages", $this->_path);
19 19
         bind_textdomain_codeset('messages', 'UTF-8');
20
-		textdomain("messages");
20
+        textdomain("messages");
21 21
 
22
-		return $this;
23
-	}
22
+        return $this;
23
+    }
24 24
 
25
-	/**
26
-	 * Returns gettext translation for $slug in $language
27
-	 *
28
-	 * @see http://php.net/gettext
29
-	 * @param string $slug
30
-	 * @param string $language
31
-	 * @return string
32
-	 */
33
-	protected function _translate($slug, $language = false)
34
-	{
35
-		return gettext($slug);
36
-	}
25
+    /**
26
+     * Returns gettext translation for $slug in $language
27
+     *
28
+     * @see http://php.net/gettext
29
+     * @param string $slug
30
+     * @param string $language
31
+     * @return string
32
+     */
33
+    protected function _translate($slug, $language = false)
34
+    {
35
+        return gettext($slug);
36
+    }
37 37
 
38 38
 }
Please login to merge, or discard this patch.
src/inflector/Inflector.php 1 patch
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -80,6 +80,9 @@  discard block
 block discarded – undo
80 80
         return $this->doInflection('unclassify', $word);
81 81
     }
82 82
 
83
+    /**
84
+     * @param string|null $word
85
+     */
83 86
     public function underscore($word)
84 87
     {
85 88
         return $this->doInflection('underscore', $word);
@@ -90,6 +93,9 @@  discard block
 block discarded – undo
90 93
         return $this->doInflection('singularize', $word);
91 94
     }
92 95
 
96
+    /**
97
+     * @return string
98
+     */
93 99
     public function pluralize($word)
94 100
     {
95 101
         return $this->doInflection('pluralize', $word);
Please login to merge, or discard this patch.
src/Logger/Manager.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -12,11 +12,17 @@
 block discarded – undo
12 12
 	protected $_adapter;
13 13
 	protected $_eventTypes = array(self::EVENT_ERROR, self::EVENT_WARNING, self::EVENT_NOTICE, self::EVENT_INFO);
14 14
 
15
+	/**
16
+	 * @param string $data
17
+	 */
15 18
 	public function error($data)
16 19
 	{
17 20
 		$this->logEvent(self::EVENT_ERROR, $data);
18 21
 	}
19 22
 
23
+	/**
24
+	 * @param string $data
25
+	 */
20 26
 	public function info($data)
21 27
 	{
22 28
 		$this->logEvent(self::EVENT_INFO, $data);
Please login to merge, or discard this patch.
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -4,87 +4,87 @@
 block discarded – undo
4 4
 
5 5
 class Manager
6 6
 {
7
-	const EVENT_ERROR = 'error';
8
-	const EVENT_WARNING = 'warning';
9
-	const EVENT_NOTICE = 'notice';
10
-	const EVENT_INFO = 'info';
11
-
12
-	protected $_adapter;
13
-	protected $_eventTypes = array(self::EVENT_ERROR, self::EVENT_WARNING, self::EVENT_NOTICE, self::EVENT_INFO);
14
-
15
-	public function error($data)
16
-	{
17
-		$this->logEvent(self::EVENT_ERROR, $data);
18
-	}
19
-
20
-	public function info($data)
21
-	{
22
-		$this->logEvent(self::EVENT_INFO, $data);
23
-	}
24
-
25
-	public function logEvent($type = self::EVENT_INFO, $data = null)
26
-	{
27
-		$event = Event::getNew($type);
28
-		$event->setData($data);
29
-		$event->setBacktrace(debug_backtrace());
30
-
31
-		$this->getAdapter()->addEvent($event);
32
-	}
33
-
34
-	public function errorHandler($code, $string, $file, $line)
35
-	{
36
-		if (error_reporting() == 0) {
37
-			return;
38
-		}
39
-
40
-		$string .= " in $file on $line";
41
-		switch ($code) {
42
-			case E_WARNING:
43
-			case E_USER_WARNING:
44
-				$this->error($string);
45
-				break;
46
-
47
-			case E_NOTICE:
48
-			case E_USER_NOTICE:
49
-				$this->info($string);
50
-				break;
51
-
52
-			case E_ERROR:
53
-			case E_USER_ERROR:
54
-				restore_error_handler();
55
-				trigger_error($string, E_USER_ERROR);
56
-				break;
57
-			default:
58
-				$this->error($string);
59
-				break;
60
-		}
61
-	}
62
-
63
-	public function output()
64
-	{
65
-		return $this->getAdapter()->output($this->_events);
66
-	}
67
-
68
-	public function addEventType($type)
69
-	{
70
-		if (!in_array($type, $this->getEventTypes())) {
71
-			$this->_eventTypes[] = $type;
72
-		}
73
-	}
74
-
75
-	public function getEventTypes()
76
-	{
77
-		return $this->_eventTypes;
78
-	}
79
-
80
-	public function setAdapter(\Nip\Logger\Adapter\AdapterAbstract $adapter)
81
-	{
82
-		$this->_adapter = $adapter;
83
-	}
84
-
85
-	public function getAdapter()
86
-	{
87
-		return $this->_adapter;
88
-	}
7
+    const EVENT_ERROR = 'error';
8
+    const EVENT_WARNING = 'warning';
9
+    const EVENT_NOTICE = 'notice';
10
+    const EVENT_INFO = 'info';
11
+
12
+    protected $_adapter;
13
+    protected $_eventTypes = array(self::EVENT_ERROR, self::EVENT_WARNING, self::EVENT_NOTICE, self::EVENT_INFO);
14
+
15
+    public function error($data)
16
+    {
17
+        $this->logEvent(self::EVENT_ERROR, $data);
18
+    }
19
+
20
+    public function info($data)
21
+    {
22
+        $this->logEvent(self::EVENT_INFO, $data);
23
+    }
24
+
25
+    public function logEvent($type = self::EVENT_INFO, $data = null)
26
+    {
27
+        $event = Event::getNew($type);
28
+        $event->setData($data);
29
+        $event->setBacktrace(debug_backtrace());
30
+
31
+        $this->getAdapter()->addEvent($event);
32
+    }
33
+
34
+    public function errorHandler($code, $string, $file, $line)
35
+    {
36
+        if (error_reporting() == 0) {
37
+            return;
38
+        }
39
+
40
+        $string .= " in $file on $line";
41
+        switch ($code) {
42
+            case E_WARNING:
43
+            case E_USER_WARNING:
44
+                $this->error($string);
45
+                break;
46
+
47
+            case E_NOTICE:
48
+            case E_USER_NOTICE:
49
+                $this->info($string);
50
+                break;
51
+
52
+            case E_ERROR:
53
+            case E_USER_ERROR:
54
+                restore_error_handler();
55
+                trigger_error($string, E_USER_ERROR);
56
+                break;
57
+            default:
58
+                $this->error($string);
59
+                break;
60
+        }
61
+    }
62
+
63
+    public function output()
64
+    {
65
+        return $this->getAdapter()->output($this->_events);
66
+    }
67
+
68
+    public function addEventType($type)
69
+    {
70
+        if (!in_array($type, $this->getEventTypes())) {
71
+            $this->_eventTypes[] = $type;
72
+        }
73
+    }
74
+
75
+    public function getEventTypes()
76
+    {
77
+        return $this->_eventTypes;
78
+    }
79
+
80
+    public function setAdapter(\Nip\Logger\Adapter\AdapterAbstract $adapter)
81
+    {
82
+        $this->_adapter = $adapter;
83
+    }
84
+
85
+    public function getAdapter()
86
+    {
87
+        return $this->_adapter;
88
+    }
89 89
     
90 90
 }
91 91
\ No newline at end of file
Please login to merge, or discard this patch.
src/Mailer.php 2 patches
Doc Comments   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 * @param string $host
29 29
 	 * @param string $username
30 30
 	 * @param string $password
31
-	 * @return Nip_ViewEmail
31
+	 * @return Nip_Mailer
32 32
 	 */
33 33
 	public function authSMTP($host, $username, $password)
34 34
 	{
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
 	/**
50 50
 	 * Sets flag to show SMTP debugging information
51
-	 * @return Nip_ViewEmail
51
+	 * @return Nip_Mailer
52 52
 	 */
53 53
 	public function debugSMTP()
54 54
 	{
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	/**
60 60
 	 * @param string $address
61 61
 	 * @param string $name
62
-	 * @return Nip_ViewEmail
62
+	 * @return Nip_Mailer
63 63
 	 */
64 64
 	public function setFrom($address, $name = false)
65 65
 	{
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	/**
74 74
 	 * @param string $address
75 75
 	 * @param string $name
76
-	 * @return Nip_ViewEmail
76
+	 * @return Nip_Mailer
77 77
 	 */
78 78
 	public function addTo($address, $name = false)
79 79
 	{
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	/**
85 85
 	 * @param string $address
86 86
 	 * @param string $name
87
-	 * @return Nip_ViewEmail
87
+	 * @return Nip_Mailer
88 88
 	 */
89 89
 	public function addBCC($address, $name = '')
90 90
 	{
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	/**
96 96
 	 * @param string $address
97 97
 	 * @param string $name
98
-	 * @return Nip_ViewEmail
98
+	 * @return Nip_Mailer
99 99
 	 */
100 100
 	public function addReplyTo($address, $name = false)
101 101
 	{
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	}
105 105
 
106 106
 	/**
107
-	 * @return Nip_View_Email
107
+	 * @return Nip_Mailer
108 108
 	 */
109 109
 	public function clearAllRecipients()
110 110
 	{
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 
115 115
 	/**
116 116
 	 * @param string $subject
117
-	 * @return Nip_ViewEmail
117
+	 * @return Nip_Mailer
118 118
 	 */
119 119
 	public function setSubject($subject)
120 120
 	{
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 *
128 128
 	 * @param string $path
129 129
 	 * @param string $name
130
-	 * @return Nip_ViewEmail
130
+	 * @return Nip_Mailer
131 131
 	 */
132 132
 	public function addAttachment($path, $name = '')
133 133
 	{
Please login to merge, or discard this patch.
Indentation   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -3,165 +3,165 @@
 block discarded – undo
3 3
 class Nip_Mailer
4 4
 {
5 5
 
6
-	protected $_mail;
6
+    protected $_mail;
7 7
 
8
-	public function __construct()
9
-	{
10
-		$this->_mail = new PHPMailer();
8
+    public function __construct()
9
+    {
10
+        $this->_mail = new PHPMailer();
11 11
         $this->_mail->CharSet = "UTF-8";
12 12
 //		$this->_mail->SMTPDebug = true;
13 13
 
14
-		$config = Nip_Config::instance()->parse(CONFIG_PATH . 'smtp.ini');
15
-		if ($config->SMTP->host) {
14
+        $config = Nip_Config::instance()->parse(CONFIG_PATH . 'smtp.ini');
15
+        if ($config->SMTP->host) {
16 16
             $this->_mail->IsSMTP();
17
-			if ($config->SMTP->username) {
18
-				$this->authSMTP($config->SMTP->host, $config->SMTP->username, $config->SMTP->password);				
19
-			} else {				
17
+            if ($config->SMTP->username) {
18
+                $this->authSMTP($config->SMTP->host, $config->SMTP->username, $config->SMTP->password);				
19
+            } else {				
20 20
                 $this->_mail->Host = $config->SMTP->host;
21
-			}
22
-		}
23
-
24
-		$this->setFrom($config->EMAIL->from, $config->EMAIL->from_name);
25
-	}
26
-
27
-	/**
28
-	 * @param string $host
29
-	 * @param string $username
30
-	 * @param string $password
31
-	 * @return Nip_ViewEmail
32
-	 */
33
-	public function authSMTP($host, $username, $password)
34
-	{
35
-		$this->_mail->IsSMTP();
36
-
37
-		$this->_mail->SMTPAuth = true;
38
-		$this->_mail->Host = $host;
39
-		$this->_mail->Username = $username;
40
-		$this->_mail->Password = $password;
41
-
42
-		return $this;
43
-	}
21
+            }
22
+        }
23
+
24
+        $this->setFrom($config->EMAIL->from, $config->EMAIL->from_name);
25
+    }
26
+
27
+    /**
28
+     * @param string $host
29
+     * @param string $username
30
+     * @param string $password
31
+     * @return Nip_ViewEmail
32
+     */
33
+    public function authSMTP($host, $username, $password)
34
+    {
35
+        $this->_mail->IsSMTP();
36
+
37
+        $this->_mail->SMTPAuth = true;
38
+        $this->_mail->Host = $host;
39
+        $this->_mail->Username = $username;
40
+        $this->_mail->Password = $password;
41
+
42
+        return $this;
43
+    }
44 44
     
45 45
     public function IsHTML($bool) {
46 46
         $this->_mail->IsHTML($bool);
47 47
     }
48 48
 
49
-	/**
50
-	 * Sets flag to show SMTP debugging information
51
-	 * @return Nip_ViewEmail
52
-	 */
53
-	public function debugSMTP()
54
-	{
55
-		$this->_mail->SMTPDebug = PHP_INT_MAX;
56
-		return $this;
57
-	}
58
-
59
-	/**
60
-	 * @param string $address
61
-	 * @param string $name
62
-	 * @return Nip_ViewEmail
63
-	 */
64
-	public function setFrom($address, $name = false)
65
-	{
66
-		$this->_mail->From = $address;
67
-		if ($name) {
68
-			$this->_mail->FromName = $name;
69
-		}
70
-		return $this;
71
-	}
72
-
73
-	/**
74
-	 * @param string $address
75
-	 * @param string $name
76
-	 * @return Nip_ViewEmail
77
-	 */
78
-	public function addTo($address, $name = false)
79
-	{
80
-		$this->_mail->AddAddress($address, $name);
81
-		return $this;
82
-	}
83
-
84
-	/**
85
-	 * @param string $address
86
-	 * @param string $name
87
-	 * @return Nip_ViewEmail
88
-	 */
89
-	public function addBCC($address, $name = '')
90
-	{
91
-		$this->_mail->AddBCC($address, $name);
92
-		return $this;
93
-	}
94
-
95
-	/**
96
-	 * @param string $address
97
-	 * @param string $name
98
-	 * @return Nip_ViewEmail
99
-	 */
100
-	public function addReplyTo($address, $name = false)
101
-	{
102
-		$this->_mail->AddReplyTo($address, $name);
103
-		return $this;
104
-	}
105
-
106
-	/**
107
-	 * @return Nip_View_Email
108
-	 */
109
-	public function clearAllRecipients()
110
-	{
111
-		$this->_mail->ClearAllRecipients();
112
-		return $this;
113
-	}
114
-
115
-	/**
116
-	 * @param string $subject
117
-	 * @return Nip_ViewEmail
118
-	 */
119
-	public function setSubject($subject)
120
-	{
121
-		$this->_mail->Subject = $subject;
122
-		return $this;
123
-	}
124
-
125
-	/**
126
-	 * Adds attachment
127
-	 *
128
-	 * @param string $path
129
-	 * @param string $name
130
-	 * @return Nip_ViewEmail
131
-	 */
132
-	public function addAttachment($path, $name = '')
133
-	{
134
-		$this->_mail->AddAttachment($path, $name);
135
-		return $this;
136
-	}
137
-
138
-	public function send()
139
-	{
140
-		$return = $this->_mail->Send();
141
-
142
-		if (!$return) {
143
-			$return = $this->_mail->ErrorInfo;
144
-		}
49
+    /**
50
+     * Sets flag to show SMTP debugging information
51
+     * @return Nip_ViewEmail
52
+     */
53
+    public function debugSMTP()
54
+    {
55
+        $this->_mail->SMTPDebug = PHP_INT_MAX;
56
+        return $this;
57
+    }
58
+
59
+    /**
60
+     * @param string $address
61
+     * @param string $name
62
+     * @return Nip_ViewEmail
63
+     */
64
+    public function setFrom($address, $name = false)
65
+    {
66
+        $this->_mail->From = $address;
67
+        if ($name) {
68
+            $this->_mail->FromName = $name;
69
+        }
70
+        return $this;
71
+    }
72
+
73
+    /**
74
+     * @param string $address
75
+     * @param string $name
76
+     * @return Nip_ViewEmail
77
+     */
78
+    public function addTo($address, $name = false)
79
+    {
80
+        $this->_mail->AddAddress($address, $name);
81
+        return $this;
82
+    }
83
+
84
+    /**
85
+     * @param string $address
86
+     * @param string $name
87
+     * @return Nip_ViewEmail
88
+     */
89
+    public function addBCC($address, $name = '')
90
+    {
91
+        $this->_mail->AddBCC($address, $name);
92
+        return $this;
93
+    }
94
+
95
+    /**
96
+     * @param string $address
97
+     * @param string $name
98
+     * @return Nip_ViewEmail
99
+     */
100
+    public function addReplyTo($address, $name = false)
101
+    {
102
+        $this->_mail->AddReplyTo($address, $name);
103
+        return $this;
104
+    }
105
+
106
+    /**
107
+     * @return Nip_View_Email
108
+     */
109
+    public function clearAllRecipients()
110
+    {
111
+        $this->_mail->ClearAllRecipients();
112
+        return $this;
113
+    }
114
+
115
+    /**
116
+     * @param string $subject
117
+     * @return Nip_ViewEmail
118
+     */
119
+    public function setSubject($subject)
120
+    {
121
+        $this->_mail->Subject = $subject;
122
+        return $this;
123
+    }
124
+
125
+    /**
126
+     * Adds attachment
127
+     *
128
+     * @param string $path
129
+     * @param string $name
130
+     * @return Nip_ViewEmail
131
+     */
132
+    public function addAttachment($path, $name = '')
133
+    {
134
+        $this->_mail->AddAttachment($path, $name);
135
+        return $this;
136
+    }
137
+
138
+    public function send()
139
+    {
140
+        $return = $this->_mail->Send();
141
+
142
+        if (!$return) {
143
+            $return = $this->_mail->ErrorInfo;
144
+        }
145 145
 		
146
-		return $return;
147
-	}
146
+        return $return;
147
+    }
148 148
 
149 149
 
150
-	public function setBody($body)
151
-	{
152
-		$this->_mail->Body = $body;
153
-		return $this;
154
-	}
150
+    public function setBody($body)
151
+    {
152
+        $this->_mail->Body = $body;
153
+        return $this;
154
+    }
155 155
 
156
-	public function getBody()
157
-	{
158
-		return $this->_mail->Body;
159
-	}
156
+    public function getBody()
157
+    {
158
+        return $this->_mail->Body;
159
+    }
160 160
    
161
-	public function setAltBody($body)
162
-	{
163
-		$this->_mail->AltBody = $body;
164
-		return $this;
165
-	}
161
+    public function setAltBody($body)
162
+    {
163
+        $this->_mail->AltBody = $body;
164
+        return $this;
165
+    }
166 166
 
167 167
 }
168 168
\ No newline at end of file
Please login to merge, or discard this patch.