File tree Expand file tree Collapse file tree 5 files changed +31
-32
lines changed
Expand file tree Collapse file tree 5 files changed +31
-32
lines changed Original file line number Diff line number Diff line change @@ -6,8 +6,7 @@ class CouldNotSendNotification extends \Exception
66{
77 public static function serviceRespondedWithAnError ($ response )
88 {
9- return new static ("Couldn't post Twitter status. Error: " . $ response ->errors [0 ]->code . ' Message: ' .
10- $ response ->errors [0 ]->message );
9+ return new static ("Couldn't post Twitter status. Error: {$ response ->errors [0 ]->code } Message: {$ response ->errors [0 ]->message }" );
1110 }
1211
1312}
Original file line number Diff line number Diff line change 77
88class Twitter
99{
10-
11- /** @var mixed @var string */
12- protected $ consumer_key ;
13-
14- /** @var mixed @var string */
15- protected $ consumer_secret ;
16-
17- /** @var mixed @var string */
18- protected $ access_token ;
19-
20- /** @var mixed @var string */
21- protected $ access_secret ;
22-
23- /** @var TwitterOAuth */
10+ /** @var \Abraham\TwitterOAuth\TwitterOAuth */
2411 public $ connection ;
2512
2613 public function __construct (array $ config )
2714 {
28- $ this ->consumer_key = $ config ['consumer_key ' ];
29- $ this ->consumer_secret = $ config ['consumer_secret ' ];
30- $ this ->access_token = $ config ['access_token ' ];
31- $ this ->access_secret = $ config ['access_secret ' ];
3215 $ this ->connection = new TwitterOAuth (
33- $ this -> consumer_key ,
34- $ this -> consumer_secret ,
35- $ this -> access_token ,
36- $ this -> access_secret
16+ $ config [ ' consumer_key ' ] ,
17+ $ config [ ' consumer_secret ' ] ,
18+ $ config [ ' access_token ' ] ,
19+ $ config [ ' access_secret ' ]
3720 );
3821 }
3922}
Original file line number Diff line number Diff line change 88
99class TwitterChannel
1010{
11-
1211 /** @var Client */
1312 protected $ client ;
14- /**
15- * @var Twitter
16- */
17- private $ twitter ;
13+
14+ /** @var Twitter */
15+ protected $ twitter ;
1816
1917 /**
2018 * @param Client $client
@@ -31,6 +29,7 @@ public function __construct(Client $client, Twitter $twitter)
3129 *
3230 * @param mixed $notifiable
3331 * @param \Illuminate\Notifications\Notification $notification
32+ *
3433 * @throws CouldNotSendNotification
3534 */
3635 public function send ($ notifiable , Notification $ notification )
Original file line number Diff line number Diff line change 55class TwitterMessage
66{
77
8- /** @var string @var string */
8+ /** @var string */
99 protected $ content ;
1010
1111 /**
12- * Message constructor.
12+ * @param string $content
1313 *
14+ * @return static
15+ */
16+ public static function create ($ content = '' )
17+ {
18+ return new static ($ content );
19+ }
20+
21+ /*
1422 * @param string $content
1523 */
1624 public function __construct ($ content = '' )
@@ -20,9 +28,11 @@ public function __construct($content = '')
2028
2129 /**
2230 * Get Twitter message content
31+ *
2332 * @return string
2433 */
25- public function getContent () {
34+ public function getContent ()
35+ {
2636 return $ this ->content ;
2737 }
2838
Original file line number Diff line number Diff line change 66
77class TwitterMessageTest extends \PHPUnit_Framework_TestCase
88{
9+ /** @var TwitterMessage */
910 protected $ message ;
1011
12+ /** @test */
13+ public function it_provides_a_factory_method ()
14+ {
15+ $ message = TwitterMessage::create ('myMessage ' );
16+
17+ $ this ->assertEquals ('myMessage ' , $ message ->getContent ());
18+ }
1119
1220 /** @test */
1321 public function it_accepts_a_message_when_constructing_a_message ()
You can’t perform that action at this time.
0 commit comments