Completed
Push — develop ( 92ea44...6b6dc0 )
by
unknown
06:45 queued 03:35
created
src/wordlift/videoobject/background-process/class-videos-data-source.php 2 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -6,52 +6,52 @@
 block discarded – undo
6 6
 
7 7
 class Videos_Data_Source extends Data_Source {
8 8
 
9
-	/**
10
-	 * @var \Wordlift_Log_Service
11
-	 */
12
-	private $log;
13
-
14
-	public function __construct( $state_storage_key ) {
15
-		parent::__construct( $state_storage_key );
16
-		$this->log = \Wordlift_Log_Service::get_logger( get_class() );
17
-	}
18
-
19
-	public function next() {
20
-		$this->log->debug( "Received video data source index as " . $this->get_state()->index );
21
-		$this->log->debug( "Count set to " . $this->get_batch_size() );
22
-
23
-		return get_posts( array(
24
-			'fields'      => 'ids',
25
-			'post_status' => 'any',
26
-			'numberposts' => $this->get_batch_size(),
27
-			'offset'      => $this->get_state()->index,
28
-			/**
29
-			 * @since 3.31.4
30
-			 * Filter name : wl_videoobject_procedure_post_types
31
-			 * @return array<string> An array of supported post types for the video import procedure.
32
-			 */
33
-			'post_type'   => apply_filters( 'wl_videoobject_procedure_post_types', array( 'post' ) )
34
-		) );
35
-	}
36
-
37
-	public function count() {
38
-		return count( get_posts( array(
39
-			'fields'      => 'ids',
40
-			'numberposts' => - 1,
41
-			'post_status' => 'any',
42
-			/**
43
-			 * @since 3.31.4
44
-			 * Filter name : wl_videoobject_procedure_post_types
45
-			 * @return array<string> An array of supported post types for the video import procedure.
46
-			 */
47
-			'post_type'   => apply_filters( 'wl_videoobject_procedure_post_types', array( 'post' ) )
48
-		) ) );
49
-
50
-	}
51
-
52
-	public function get_batch_size() {
53
-		// For now use only 5 in order to prevent exceeding api limit.
54
-		return 5;
55
-	}
9
+    /**
10
+     * @var \Wordlift_Log_Service
11
+     */
12
+    private $log;
13
+
14
+    public function __construct( $state_storage_key ) {
15
+        parent::__construct( $state_storage_key );
16
+        $this->log = \Wordlift_Log_Service::get_logger( get_class() );
17
+    }
18
+
19
+    public function next() {
20
+        $this->log->debug( "Received video data source index as " . $this->get_state()->index );
21
+        $this->log->debug( "Count set to " . $this->get_batch_size() );
22
+
23
+        return get_posts( array(
24
+            'fields'      => 'ids',
25
+            'post_status' => 'any',
26
+            'numberposts' => $this->get_batch_size(),
27
+            'offset'      => $this->get_state()->index,
28
+            /**
29
+             * @since 3.31.4
30
+             * Filter name : wl_videoobject_procedure_post_types
31
+             * @return array<string> An array of supported post types for the video import procedure.
32
+             */
33
+            'post_type'   => apply_filters( 'wl_videoobject_procedure_post_types', array( 'post' ) )
34
+        ) );
35
+    }
36
+
37
+    public function count() {
38
+        return count( get_posts( array(
39
+            'fields'      => 'ids',
40
+            'numberposts' => - 1,
41
+            'post_status' => 'any',
42
+            /**
43
+             * @since 3.31.4
44
+             * Filter name : wl_videoobject_procedure_post_types
45
+             * @return array<string> An array of supported post types for the video import procedure.
46
+             */
47
+            'post_type'   => apply_filters( 'wl_videoobject_procedure_post_types', array( 'post' ) )
48
+        ) ) );
49
+
50
+    }
51
+
52
+    public function get_batch_size() {
53
+        // For now use only 5 in order to prevent exceeding api limit.
54
+        return 5;
55
+    }
56 56
 
57 57
 }
58 58
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -11,16 +11,16 @@  discard block
 block discarded – undo
11 11
 	 */
12 12
 	private $log;
13 13
 
14
-	public function __construct( $state_storage_key ) {
15
-		parent::__construct( $state_storage_key );
16
-		$this->log = \Wordlift_Log_Service::get_logger( get_class() );
14
+	public function __construct($state_storage_key) {
15
+		parent::__construct($state_storage_key);
16
+		$this->log = \Wordlift_Log_Service::get_logger(get_class());
17 17
 	}
18 18
 
19 19
 	public function next() {
20
-		$this->log->debug( "Received video data source index as " . $this->get_state()->index );
21
-		$this->log->debug( "Count set to " . $this->get_batch_size() );
20
+		$this->log->debug("Received video data source index as ".$this->get_state()->index);
21
+		$this->log->debug("Count set to ".$this->get_batch_size());
22 22
 
23
-		return get_posts( array(
23
+		return get_posts(array(
24 24
 			'fields'      => 'ids',
25 25
 			'post_status' => 'any',
26 26
 			'numberposts' => $this->get_batch_size(),
@@ -30,22 +30,22 @@  discard block
 block discarded – undo
30 30
 			 * Filter name : wl_videoobject_procedure_post_types
31 31
 			 * @return array<string> An array of supported post types for the video import procedure.
32 32
 			 */
33
-			'post_type'   => apply_filters( 'wl_videoobject_procedure_post_types', array( 'post' ) )
34
-		) );
33
+			'post_type'   => apply_filters('wl_videoobject_procedure_post_types', array('post'))
34
+		));
35 35
 	}
36 36
 
37 37
 	public function count() {
38
-		return count( get_posts( array(
38
+		return count(get_posts(array(
39 39
 			'fields'      => 'ids',
40
-			'numberposts' => - 1,
40
+			'numberposts' => -1,
41 41
 			'post_status' => 'any',
42 42
 			/**
43 43
 			 * @since 3.31.4
44 44
 			 * Filter name : wl_videoobject_procedure_post_types
45 45
 			 * @return array<string> An array of supported post types for the video import procedure.
46 46
 			 */
47
-			'post_type'   => apply_filters( 'wl_videoobject_procedure_post_types', array( 'post' ) )
48
-		) ) );
47
+			'post_type'   => apply_filters('wl_videoobject_procedure_post_types', array('post'))
48
+		)));
49 49
 
50 50
 	}
51 51
 
Please login to merge, or discard this patch.
src/wordlift/videoobject/class-video-processor.php 2 patches
Indentation   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -11,156 +11,156 @@
 block discarded – undo
11 11
 
12 12
 class Video_Processor {
13 13
 
14
-	private function get_data_for_videos( $embedded_videos ) {
15
-
16
-		$youtube_videos = $this->get_youtube_videos( $embedded_videos );
17
-
18
-		$youtube_provider = Provider_Factory::get_provider( Provider_Factory::YOUTUBE );
19
-		$youtube_videos   = $youtube_provider->get_videos_data( $youtube_videos );
20
-
21
-		$vimeo_videos = $this->get_vimeo_videos( $embedded_videos );
22
-
23
-		$vimeo_provider = Provider_Factory::get_provider( Provider_Factory::VIMEO );
24
-		$vimeo_videos   = $vimeo_provider->get_videos_data( $vimeo_videos );
25
-
26
-		return array_merge( $youtube_videos, $vimeo_videos );
27
-
28
-	}
29
-
30
-	/**
31
-	 * @param $storage Storage
32
-	 * @param $post_id int
33
-	 * @param $embedded_videos array<Embedded_Video>
34
-	 */
35
-	private function remove_videos_from_store_if_not_present_in_content( $storage, $post_id, $embedded_videos ) {
36
-
37
-		$videos_to_be_deleted = $this->get_videos_to_be_deleted( $storage, $post_id, $embedded_videos );
38
-		$storage->remove_videos( $videos_to_be_deleted, $post_id );
39
-
40
-	}
41
-
42
-	/**
43
-	 * @param Storage $storage
44
-	 * @param $post_id
45
-	 * @param array $embedded_videos
46
-	 *
47
-	 * @return array
48
-	 */
49
-	private function get_videos_to_be_deleted( Storage $storage, $post_id, array $embedded_videos ) {
50
-		$videos_in_store     = $storage->get_all_videos( $post_id );
51
-		$embedded_video_urls = array_map( function ( $embedded_video ) {
52
-			/**
53
-			 * @var $embedded_video Embedded_Video
54
-			 */
55
-			return $embedded_video->get_url();
56
-		}, $embedded_videos );
57
-
58
-		return array_filter( $videos_in_store, function ( $video ) use ( $embedded_video_urls ) {
59
-			/**
60
-			 * @var $video Video
61
-			 */
62
-			return ! in_array( $video->id, $embedded_video_urls );
63
-		} );
64
-	}
65
-
66
-	/**
67
-	 * @param \WP_Post $post
68
-	 * @param $post_id
69
-	 */
70
-	public function process_video_urls( \WP_Post $post, $post_id ) {
71
-
72
-		$parser = Parser_Factory::get_parser_from_content( $post->post_content );
73
-
74
-		$embedded_videos = $parser->get_videos( $post_id );
75
-
76
-		/**
77
-		 * Filters the embedded videos on post contet, custom plugins can add their video urls
78
-		 * by constructing \Default_Embedded_Video or implement Embedded_Video class
79
-		 * @since 3.31.4
80
-		 * Filter name : wl_videoobject_embedded_videos
81
-		 * @param $embedded_videos array<Embedded_Video>
82
-		 * @return array<Embedded_Video>
83
-		 */
84
-		$embedded_videos = apply_filters('wl_videoobject_embedded_videos', $embedded_videos);
85
-
86
-		$storage = Video_Storage_Factory::get_storage();
87
-
88
-		// Before sending api requests we need to check if there are any videos in
89
-		// store which is not present on post content, remove them if there are
90
-		// any
91
-		$this->remove_videos_from_store_if_not_present_in_content( $storage, $post_id, $embedded_videos );
92
-
93
-		$embedded_videos = $this->get_videos_without_existing_data( $storage, $post_id, $embedded_videos );
94
-
95
-		// Return early after removing all the videos.
96
-		if ( ! $embedded_videos ) {
97
-			return;
98
-		}
99
-
100
-		$videos = $this->get_data_for_videos( $embedded_videos );
101
-
102
-		if ( ! $videos ) {
103
-			return;
104
-		}
105
-
106
-		foreach ( $videos as $video ) {
107
-			$storage->add_video( $post_id, $video );
108
-		}
109
-	}
110
-
111
-	/**
112
-	 * @param $storage Storage
113
-	 * @param $post_id int
114
-	 * @param $embedded_videos array<Embedded_Video>
115
-	 *
116
-	 * @return array<Embedded_Video> Return array of embedded videos which are not in store.
117
-	 */
118
-	private function get_videos_without_existing_data( $storage, $post_id, $embedded_videos ) {
119
-		$videos_in_store    = $storage->get_all_videos( $post_id );
120
-		$video_ids_in_store = array_map( function ( $video ) {
121
-			return $video->id;
122
-		}, $videos_in_store );
123
-
124
-		return array_filter( $embedded_videos, function ( $embedded_video ) use ( $video_ids_in_store ) {
125
-			return ! in_array( $embedded_video->get_url(), $video_ids_in_store );
126
-		} );
127
-	}
128
-
129
-	/**
130
-	 * @param $embedded_videos
131
-	 *
132
-	 * @return array
133
-	 */
134
-	private function get_youtube_videos( $embedded_videos ) {
135
-		return array_filter( $embedded_videos, function ( $embedded_video ) {
136
-			/**
137
-			 * it should have youtube.com or youtu.be in the url
138
-			 *
139
-			 * @param $embedded_video Embedded_Video
140
-			 */
141
-			$video_url = $embedded_video->get_url();
142
-
143
-			return strpos( $video_url, "youtube.com" ) !== false ||
144
-			       strpos( $video_url, "youtu.be" ) !== false;
145
-		} );
146
-	}
147
-
148
-	/**
149
-	 * @param $embedded_videos
150
-	 *
151
-	 * @return array
152
-	 */
153
-	private function get_vimeo_videos( $embedded_videos ) {
154
-		return array_filter( $embedded_videos, function ( $embedded_video ) {
155
-			/**
156
-			 * it should have vimeo.com in the url
157
-			 *
158
-			 * @param $embedded_video Embedded_Video
159
-			 */
160
-			$video_url = $embedded_video->get_url();
161
-
162
-			return strpos( $video_url, "vimeo.com" ) !== false;
163
-		} );
164
-	}
14
+    private function get_data_for_videos( $embedded_videos ) {
15
+
16
+        $youtube_videos = $this->get_youtube_videos( $embedded_videos );
17
+
18
+        $youtube_provider = Provider_Factory::get_provider( Provider_Factory::YOUTUBE );
19
+        $youtube_videos   = $youtube_provider->get_videos_data( $youtube_videos );
20
+
21
+        $vimeo_videos = $this->get_vimeo_videos( $embedded_videos );
22
+
23
+        $vimeo_provider = Provider_Factory::get_provider( Provider_Factory::VIMEO );
24
+        $vimeo_videos   = $vimeo_provider->get_videos_data( $vimeo_videos );
25
+
26
+        return array_merge( $youtube_videos, $vimeo_videos );
27
+
28
+    }
29
+
30
+    /**
31
+     * @param $storage Storage
32
+     * @param $post_id int
33
+     * @param $embedded_videos array<Embedded_Video>
34
+     */
35
+    private function remove_videos_from_store_if_not_present_in_content( $storage, $post_id, $embedded_videos ) {
36
+
37
+        $videos_to_be_deleted = $this->get_videos_to_be_deleted( $storage, $post_id, $embedded_videos );
38
+        $storage->remove_videos( $videos_to_be_deleted, $post_id );
39
+
40
+    }
41
+
42
+    /**
43
+     * @param Storage $storage
44
+     * @param $post_id
45
+     * @param array $embedded_videos
46
+     *
47
+     * @return array
48
+     */
49
+    private function get_videos_to_be_deleted( Storage $storage, $post_id, array $embedded_videos ) {
50
+        $videos_in_store     = $storage->get_all_videos( $post_id );
51
+        $embedded_video_urls = array_map( function ( $embedded_video ) {
52
+            /**
53
+             * @var $embedded_video Embedded_Video
54
+             */
55
+            return $embedded_video->get_url();
56
+        }, $embedded_videos );
57
+
58
+        return array_filter( $videos_in_store, function ( $video ) use ( $embedded_video_urls ) {
59
+            /**
60
+             * @var $video Video
61
+             */
62
+            return ! in_array( $video->id, $embedded_video_urls );
63
+        } );
64
+    }
65
+
66
+    /**
67
+     * @param \WP_Post $post
68
+     * @param $post_id
69
+     */
70
+    public function process_video_urls( \WP_Post $post, $post_id ) {
71
+
72
+        $parser = Parser_Factory::get_parser_from_content( $post->post_content );
73
+
74
+        $embedded_videos = $parser->get_videos( $post_id );
75
+
76
+        /**
77
+         * Filters the embedded videos on post contet, custom plugins can add their video urls
78
+         * by constructing \Default_Embedded_Video or implement Embedded_Video class
79
+         * @since 3.31.4
80
+         * Filter name : wl_videoobject_embedded_videos
81
+         * @param $embedded_videos array<Embedded_Video>
82
+         * @return array<Embedded_Video>
83
+         */
84
+        $embedded_videos = apply_filters('wl_videoobject_embedded_videos', $embedded_videos);
85
+
86
+        $storage = Video_Storage_Factory::get_storage();
87
+
88
+        // Before sending api requests we need to check if there are any videos in
89
+        // store which is not present on post content, remove them if there are
90
+        // any
91
+        $this->remove_videos_from_store_if_not_present_in_content( $storage, $post_id, $embedded_videos );
92
+
93
+        $embedded_videos = $this->get_videos_without_existing_data( $storage, $post_id, $embedded_videos );
94
+
95
+        // Return early after removing all the videos.
96
+        if ( ! $embedded_videos ) {
97
+            return;
98
+        }
99
+
100
+        $videos = $this->get_data_for_videos( $embedded_videos );
101
+
102
+        if ( ! $videos ) {
103
+            return;
104
+        }
105
+
106
+        foreach ( $videos as $video ) {
107
+            $storage->add_video( $post_id, $video );
108
+        }
109
+    }
110
+
111
+    /**
112
+     * @param $storage Storage
113
+     * @param $post_id int
114
+     * @param $embedded_videos array<Embedded_Video>
115
+     *
116
+     * @return array<Embedded_Video> Return array of embedded videos which are not in store.
117
+     */
118
+    private function get_videos_without_existing_data( $storage, $post_id, $embedded_videos ) {
119
+        $videos_in_store    = $storage->get_all_videos( $post_id );
120
+        $video_ids_in_store = array_map( function ( $video ) {
121
+            return $video->id;
122
+        }, $videos_in_store );
123
+
124
+        return array_filter( $embedded_videos, function ( $embedded_video ) use ( $video_ids_in_store ) {
125
+            return ! in_array( $embedded_video->get_url(), $video_ids_in_store );
126
+        } );
127
+    }
128
+
129
+    /**
130
+     * @param $embedded_videos
131
+     *
132
+     * @return array
133
+     */
134
+    private function get_youtube_videos( $embedded_videos ) {
135
+        return array_filter( $embedded_videos, function ( $embedded_video ) {
136
+            /**
137
+             * it should have youtube.com or youtu.be in the url
138
+             *
139
+             * @param $embedded_video Embedded_Video
140
+             */
141
+            $video_url = $embedded_video->get_url();
142
+
143
+            return strpos( $video_url, "youtube.com" ) !== false ||
144
+                   strpos( $video_url, "youtu.be" ) !== false;
145
+        } );
146
+    }
147
+
148
+    /**
149
+     * @param $embedded_videos
150
+     *
151
+     * @return array
152
+     */
153
+    private function get_vimeo_videos( $embedded_videos ) {
154
+        return array_filter( $embedded_videos, function ( $embedded_video ) {
155
+            /**
156
+             * it should have vimeo.com in the url
157
+             *
158
+             * @param $embedded_video Embedded_Video
159
+             */
160
+            $video_url = $embedded_video->get_url();
161
+
162
+            return strpos( $video_url, "vimeo.com" ) !== false;
163
+        } );
164
+    }
165 165
 
166 166
 }
167 167
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -11,19 +11,19 @@  discard block
 block discarded – undo
11 11
 
12 12
 class Video_Processor {
13 13
 
14
-	private function get_data_for_videos( $embedded_videos ) {
14
+	private function get_data_for_videos($embedded_videos) {
15 15
 
16
-		$youtube_videos = $this->get_youtube_videos( $embedded_videos );
16
+		$youtube_videos = $this->get_youtube_videos($embedded_videos);
17 17
 
18
-		$youtube_provider = Provider_Factory::get_provider( Provider_Factory::YOUTUBE );
19
-		$youtube_videos   = $youtube_provider->get_videos_data( $youtube_videos );
18
+		$youtube_provider = Provider_Factory::get_provider(Provider_Factory::YOUTUBE);
19
+		$youtube_videos   = $youtube_provider->get_videos_data($youtube_videos);
20 20
 
21
-		$vimeo_videos = $this->get_vimeo_videos( $embedded_videos );
21
+		$vimeo_videos = $this->get_vimeo_videos($embedded_videos);
22 22
 
23
-		$vimeo_provider = Provider_Factory::get_provider( Provider_Factory::VIMEO );
24
-		$vimeo_videos   = $vimeo_provider->get_videos_data( $vimeo_videos );
23
+		$vimeo_provider = Provider_Factory::get_provider(Provider_Factory::VIMEO);
24
+		$vimeo_videos   = $vimeo_provider->get_videos_data($vimeo_videos);
25 25
 
26
-		return array_merge( $youtube_videos, $vimeo_videos );
26
+		return array_merge($youtube_videos, $vimeo_videos);
27 27
 
28 28
 	}
29 29
 
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
 	 * @param $post_id int
33 33
 	 * @param $embedded_videos array<Embedded_Video>
34 34
 	 */
35
-	private function remove_videos_from_store_if_not_present_in_content( $storage, $post_id, $embedded_videos ) {
35
+	private function remove_videos_from_store_if_not_present_in_content($storage, $post_id, $embedded_videos) {
36 36
 
37
-		$videos_to_be_deleted = $this->get_videos_to_be_deleted( $storage, $post_id, $embedded_videos );
38
-		$storage->remove_videos( $videos_to_be_deleted, $post_id );
37
+		$videos_to_be_deleted = $this->get_videos_to_be_deleted($storage, $post_id, $embedded_videos);
38
+		$storage->remove_videos($videos_to_be_deleted, $post_id);
39 39
 
40 40
 	}
41 41
 
@@ -46,20 +46,20 @@  discard block
 block discarded – undo
46 46
 	 *
47 47
 	 * @return array
48 48
 	 */
49
-	private function get_videos_to_be_deleted( Storage $storage, $post_id, array $embedded_videos ) {
50
-		$videos_in_store     = $storage->get_all_videos( $post_id );
51
-		$embedded_video_urls = array_map( function ( $embedded_video ) {
49
+	private function get_videos_to_be_deleted(Storage $storage, $post_id, array $embedded_videos) {
50
+		$videos_in_store     = $storage->get_all_videos($post_id);
51
+		$embedded_video_urls = array_map(function($embedded_video) {
52 52
 			/**
53 53
 			 * @var $embedded_video Embedded_Video
54 54
 			 */
55 55
 			return $embedded_video->get_url();
56
-		}, $embedded_videos );
56
+		}, $embedded_videos);
57 57
 
58
-		return array_filter( $videos_in_store, function ( $video ) use ( $embedded_video_urls ) {
58
+		return array_filter($videos_in_store, function($video) use ($embedded_video_urls) {
59 59
 			/**
60 60
 			 * @var $video Video
61 61
 			 */
62
-			return ! in_array( $video->id, $embedded_video_urls );
62
+			return ! in_array($video->id, $embedded_video_urls);
63 63
 		} );
64 64
 	}
65 65
 
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
 	 * @param \WP_Post $post
68 68
 	 * @param $post_id
69 69
 	 */
70
-	public function process_video_urls( \WP_Post $post, $post_id ) {
70
+	public function process_video_urls(\WP_Post $post, $post_id) {
71 71
 
72
-		$parser = Parser_Factory::get_parser_from_content( $post->post_content );
72
+		$parser = Parser_Factory::get_parser_from_content($post->post_content);
73 73
 
74
-		$embedded_videos = $parser->get_videos( $post_id );
74
+		$embedded_videos = $parser->get_videos($post_id);
75 75
 
76 76
 		/**
77 77
 		 * Filters the embedded videos on post contet, custom plugins can add their video urls
@@ -88,23 +88,23 @@  discard block
 block discarded – undo
88 88
 		// Before sending api requests we need to check if there are any videos in
89 89
 		// store which is not present on post content, remove them if there are
90 90
 		// any
91
-		$this->remove_videos_from_store_if_not_present_in_content( $storage, $post_id, $embedded_videos );
91
+		$this->remove_videos_from_store_if_not_present_in_content($storage, $post_id, $embedded_videos);
92 92
 
93
-		$embedded_videos = $this->get_videos_without_existing_data( $storage, $post_id, $embedded_videos );
93
+		$embedded_videos = $this->get_videos_without_existing_data($storage, $post_id, $embedded_videos);
94 94
 
95 95
 		// Return early after removing all the videos.
96
-		if ( ! $embedded_videos ) {
96
+		if ( ! $embedded_videos) {
97 97
 			return;
98 98
 		}
99 99
 
100
-		$videos = $this->get_data_for_videos( $embedded_videos );
100
+		$videos = $this->get_data_for_videos($embedded_videos);
101 101
 
102
-		if ( ! $videos ) {
102
+		if ( ! $videos) {
103 103
 			return;
104 104
 		}
105 105
 
106
-		foreach ( $videos as $video ) {
107
-			$storage->add_video( $post_id, $video );
106
+		foreach ($videos as $video) {
107
+			$storage->add_video($post_id, $video);
108 108
 		}
109 109
 	}
110 110
 
@@ -115,14 +115,14 @@  discard block
 block discarded – undo
115 115
 	 *
116 116
 	 * @return array<Embedded_Video> Return array of embedded videos which are not in store.
117 117
 	 */
118
-	private function get_videos_without_existing_data( $storage, $post_id, $embedded_videos ) {
119
-		$videos_in_store    = $storage->get_all_videos( $post_id );
120
-		$video_ids_in_store = array_map( function ( $video ) {
118
+	private function get_videos_without_existing_data($storage, $post_id, $embedded_videos) {
119
+		$videos_in_store    = $storage->get_all_videos($post_id);
120
+		$video_ids_in_store = array_map(function($video) {
121 121
 			return $video->id;
122
-		}, $videos_in_store );
122
+		}, $videos_in_store);
123 123
 
124
-		return array_filter( $embedded_videos, function ( $embedded_video ) use ( $video_ids_in_store ) {
125
-			return ! in_array( $embedded_video->get_url(), $video_ids_in_store );
124
+		return array_filter($embedded_videos, function($embedded_video) use ($video_ids_in_store) {
125
+			return ! in_array($embedded_video->get_url(), $video_ids_in_store);
126 126
 		} );
127 127
 	}
128 128
 
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 	 *
132 132
 	 * @return array
133 133
 	 */
134
-	private function get_youtube_videos( $embedded_videos ) {
135
-		return array_filter( $embedded_videos, function ( $embedded_video ) {
134
+	private function get_youtube_videos($embedded_videos) {
135
+		return array_filter($embedded_videos, function($embedded_video) {
136 136
 			/**
137 137
 			 * it should have youtube.com or youtu.be in the url
138 138
 			 *
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
 			 */
141 141
 			$video_url = $embedded_video->get_url();
142 142
 
143
-			return strpos( $video_url, "youtube.com" ) !== false ||
144
-			       strpos( $video_url, "youtu.be" ) !== false;
143
+			return strpos($video_url, "youtube.com") !== false ||
144
+			       strpos($video_url, "youtu.be") !== false;
145 145
 		} );
146 146
 	}
147 147
 
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
 	 *
151 151
 	 * @return array
152 152
 	 */
153
-	private function get_vimeo_videos( $embedded_videos ) {
154
-		return array_filter( $embedded_videos, function ( $embedded_video ) {
153
+	private function get_vimeo_videos($embedded_videos) {
154
+		return array_filter($embedded_videos, function($embedded_video) {
155 155
 			/**
156 156
 			 * it should have vimeo.com in the url
157 157
 			 *
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 			 */
160 160
 			$video_url = $embedded_video->get_url();
161 161
 
162
-			return strpos( $video_url, "vimeo.com" ) !== false;
162
+			return strpos($video_url, "vimeo.com") !== false;
163 163
 		} );
164 164
 	}
165 165
 
Please login to merge, or discard this patch.