Passed
Branch master (3591e0)
by Prabath
02:38
created
src/ApplyConfig.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -13,15 +13,15 @@
 block discarded – undo
13 13
      * @param array $required required configurations
14 14
      * @throws ConfigRequiredException
15 15
      */
16
-    public function apply_config($config, $required = []){
17
-        foreach ($config as $key => $value){
18
-            if(property_exists($this, $key)){
16
+    public function apply_config($config, $required = []) {
17
+        foreach ($config as $key => $value) {
18
+            if (property_exists($this, $key)) {
19 19
                 $this->{$key} = $value;
20 20
             }
21 21
         }
22 22
 
23
-        foreach ($required as $conf){
24
-            if(!isset($config[$conf])){
23
+        foreach ($required as $conf) {
24
+            if (!isset($config[$conf])) {
25 25
                 throw new ConfigRequiredException($conf);
26 26
             }
27 27
         }
Please login to merge, or discard this patch.
src/SocialFactory.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
      * @param array $config
17 17
      * @return SocialAdapter
18 18
      */
19
-    public function create(string $name, array $config){
19
+    public function create(string $name, array $config) {
20 20
         $class = $this->getAdapterClassname($name);
21 21
         if (!class_exists($class)) {
22 22
             throw new \RuntimeException("Class '$class' not found");
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      * @param string $name adapter name
29 29
      * @return string PSR-0 classpath
30 30
      */
31
-    private function getAdapterClassname(string $name){
31
+    private function getAdapterClassname(string $name) {
32 32
         $name = ucfirst($name);
33 33
         // replace underscores with namespace marker, PSR-0 style
34 34
         $name = str_replace('_', '\\', $name);
Please login to merge, or discard this patch.
src/MultiSocial.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
     {
39 39
         $this->factory = new SocialFactory();
40 40
 
41
-        foreach ($config as $adapterName => $adapterConfig){
41
+        foreach ($config as $adapterName => $adapterConfig) {
42 42
             $name = strtolower($adapterName);
43 43
             $this->adapters[$name] = $this->factory->create($adapterName, $adapterConfig);
44 44
         }
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      * @param string $adapterName
49 49
      * @return SocialAdapter|null
50 50
      */
51
-    public function getAdapter($adapterName){
51
+    public function getAdapter($adapterName) {
52 52
         $name = strtolower($adapterName);
53 53
         return isset($this->adapters[$name]) ? $this->adapters[$name] : null;
54 54
     }
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
      * @return array references of posts published
62 62
      * @throws exception\SocialException
63 63
      */
64
-    public function post($post){
64
+    public function post($post) {
65 65
         $references = [];
66
-        foreach ($this->adapters as $adapterName => $adapter){
66
+        foreach ($this->adapters as $adapterName => $adapter) {
67 67
             $references[$adapterName] = $adapter->post($post);
68 68
         }
69 69
         return $references;
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      * @return string post reference
79 79
      * @throws exception\SocialException
80 80
      */
81
-    public static function postTo($post, $adapterName, $config){
81
+    public static function postTo($post, $adapterName, $config) {
82 82
         $ms = new self([$adapterName => $config]);
83 83
         return array_shift($ms->post($post));
84 84
     }
Please login to merge, or discard this patch.
src/Adapter/FacebookAdapter.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -38,13 +38,13 @@  discard block
 block discarded – undo
38 38
     public function __construct($config)
39 39
     {
40 40
         $this->apply_config($config, ['app_id', 'app_secret', 'access_token', 'page_id']);
41
-        try{
41
+        try {
42 42
             $this->client = new \Facebook\Facebook([
43 43
                 'app_id' => $this->app_id,
44 44
                 'app_secret' => $this->app_secret,
45 45
                 'default_graph_version' => $this->default_graph_version,
46 46
             ]);
47
-        }catch (FacebookSDKException $ex){
47
+        }catch (FacebookSDKException $ex) {
48 48
             throw new SocialException(self::class, $ex->getMessage());
49 49
         }
50 50
     }
@@ -59,22 +59,22 @@  discard block
 block discarded – undo
59 59
             'message' => $post->getDescription(),
60 60
         ];
61 61
         $a = 0;
62
-        if(count($post->getAttachments()) > 0){
63
-            try{
62
+        if (count($post->getAttachments()) > 0) {
63
+            try {
64 64
                 $data["attached_media[{$a}]"] = $this->upload_attachments($post->getAttachments());
65
-            }catch (FacebookSDKException $ex){
65
+            }catch (FacebookSDKException $ex) {
66 66
                 throw new SocialException(self::class, $ex->getMessage());
67 67
             }
68 68
         }
69 69
 
70
-        try{
70
+        try {
71 71
             $response = $this->client->post("{$this->page_id}/feed", $data, $this->access_token);
72 72
             $id = $response->getGraphNode()->getField('id', null);
73
-        }catch (FacebookSDKException $ex){
73
+        }catch (FacebookSDKException $ex) {
74 74
             throw new SocialException(self::class, $ex->getMessage());
75 75
         }
76 76
 
77
-        if($id == null){
77
+        if ($id == null) {
78 78
             throw new SocialException(self::class, 'Error creating post');
79 79
         }
80 80
         return $id;
@@ -86,11 +86,11 @@  discard block
 block discarded – undo
86 86
      * @throws FacebookSDKException
87 87
      * @throws SocialException
88 88
      */
89
-    private function upload_attachments(array $attachments){
89
+    private function upload_attachments(array $attachments) {
90 90
         $ids = [];
91
-        foreach ($attachments as $attachment){
91
+        foreach ($attachments as $attachment) {
92 92
             $endpoint = "{$this->page_id}/photos";
93
-            if($attachment->getType() == Attachment::TYPE_VIDEO){
93
+            if ($attachment->getType() == Attachment::TYPE_VIDEO) {
94 94
                 $endpoint = "{$this->page_id}/videos";
95 95
             }
96 96
 
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
                 'source' => $this->client->fileToUpload($attachment->getPath())
101 101
             ], $this->access_token);
102 102
             $id = $response->getGraphNode()->getField('id', null);
103
-            if($id == null){
103
+            if ($id == null) {
104 104
                 throw new SocialException(self::class, 'Error uploading file');
105 105
             }
106 106
             $ids[] = $id;
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
                 'app_secret' => $this->app_secret,
45 45
                 'default_graph_version' => $this->default_graph_version,
46 46
             ]);
47
-        }catch (FacebookSDKException $ex){
47
+        } catch (FacebookSDKException $ex){
48 48
             throw new SocialException(self::class, $ex->getMessage());
49 49
         }
50 50
     }
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
         if(count($post->getAttachments()) > 0){
63 63
             try{
64 64
                 $data["attached_media[{$a}]"] = $this->upload_attachments($post->getAttachments());
65
-            }catch (FacebookSDKException $ex){
65
+            } catch (FacebookSDKException $ex){
66 66
                 throw new SocialException(self::class, $ex->getMessage());
67 67
             }
68 68
         }
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
         try{
71 71
             $response = $this->client->post("{$this->page_id}/feed", $data, $this->access_token);
72 72
             $id = $response->getGraphNode()->getField('id', null);
73
-        }catch (FacebookSDKException $ex){
73
+        } catch (FacebookSDKException $ex){
74 74
             throw new SocialException(self::class, $ex->getMessage());
75 75
         }
76 76
 
Please login to merge, or discard this patch.