@@ -47,7 +47,7 @@ class Gravatar extends AbstractHtmlElement
4747 *
4848 * @var array
4949 */
50- protected $ attribs ;
50+ protected $ attributes ;
5151
5252 /**
5353 * Email Address
@@ -86,21 +86,21 @@ class Gravatar extends AbstractHtmlElement
8686 *
8787 * @see http://pl.gravatar.com/site/implement/url
8888 * @see http://pl.gravatar.com/site/implement/url More information about gravatar's service.
89- * @param string|null $email Email address.
90- * @param null|array $options Options
91- * @param array $attribs Attributes for image tag (title, alt etc.)
89+ * @param string|null $email Email address.
90+ * @param null|array $options Options
91+ * @param array $attributes Attributes for image tag (title, alt etc.)
9292 * @return Gravatar
9393 */
94- public function __invoke ($ email = "" , $ options = [], $ attribs = [])
94+ public function __invoke ($ email = "" , $ options = [], $ attributes = [])
9595 {
9696 if (! empty ($ email )) {
9797 $ this ->setEmail ($ email );
9898 }
9999 if (! empty ($ options )) {
100100 $ this ->setOptions ($ options );
101101 }
102- if (! empty ($ attribs )) {
103- $ this ->setAttribs ( $ attribs );
102+ if (! empty ($ attributes )) {
103+ $ this ->setAttributes ( $ attributes );
104104 }
105105
106106 return $ this ;
@@ -168,28 +168,63 @@ public function getImgTag()
168168 {
169169 $ this ->setSrcAttribForImg ();
170170 $ html = '<img '
171- . $ this ->htmlAttribs ($ this ->getAttribs ())
171+ . $ this ->htmlAttribs ($ this ->getAttributes ())
172172 . $ this ->getClosingBracket ();
173173
174174 return $ html ;
175175 }
176176
177177 /**
178- * Set attribs for image tag
178+ * Set attributes for image tag
179179 *
180- * Warning! You shouldn't set src attrib for image tag.
181- * This attrib is overwritten in protected method setSrcAttribForImg().
180+ * Warning! You shouldn't set src attribute for image tag.
181+ * This attribute is overwritten in protected method setSrcAttribForImg().
182182 * This method(_setSrcAttribForImg) is called in public method getImgTag().
183183 *
184+ * @param array $attributes
185+ * @return Gravatar
186+ */
187+ public function setAttributes (array $ attributes )
188+ {
189+ $ this ->attributes = $ attributes ;
190+ return $ this ;
191+ }
192+
193+ /**
194+ * Set attribs for image tag
195+ *
184196 * @param array $attribs
185197 * @return Gravatar
198+ *
199+ * @deprecated Please use Zend\View\Helper\Gravatar::setAttributes
186200 */
187201 public function setAttribs (array $ attribs )
188202 {
189- $ this ->attribs = $ attribs ;
203+ trigger_error (sprintf (
204+ '%s is deprecated; please use %s::setAttributes ' ,
205+ __METHOD__ ,
206+ __CLASS__
207+ ), E_USER_DEPRECATED );
208+
209+ $ this ->setAttributes ($ attribs );
190210 return $ this ;
191211 }
192212
213+ /**
214+ * Get attributes of image
215+ *
216+ * Warning!
217+ * If you set src attribute, you get it, but this value will be overwritten in
218+ * protected method setSrcAttribForImg(). And finally your get other src
219+ * value!
220+ *
221+ * @return array
222+ */
223+ public function getAttributes ()
224+ {
225+ return $ this ->attributes ;
226+ }
227+
193228 /**
194229 * Get attribs of image
195230 *
@@ -199,10 +234,18 @@ public function setAttribs(array $attribs)
199234 * value!
200235 *
201236 * @return array
237+ *
238+ * @deprecated Please use Zend\View\Helper\Gravatar::getAttributes
202239 */
203240 public function getAttribs ()
204241 {
205- return $ this ->attribs ;
242+ trigger_error (sprintf (
243+ '%s is deprecated; please use %s::getAttributes ' ,
244+ __METHOD__ ,
245+ __CLASS__
246+ ), E_USER_DEPRECATED );
247+
248+ return $ this ->getAttributes ();
206249 }
207250
208251 /**
@@ -352,8 +395,8 @@ public function getSecure()
352395 */
353396 protected function setSrcAttribForImg ()
354397 {
355- $ attribs = $ this ->getAttribs ();
356- $ attribs ['src ' ] = $ this ->getAvatarUrl ();
357- $ this ->setAttribs ( $ attribs );
398+ $ attributes = $ this ->getAttributes ();
399+ $ attributes ['src ' ] = $ this ->getAvatarUrl ();
400+ $ this ->setAttributes ( $ attributes );
358401 }
359402}
0 commit comments