Skip to content

Commit

Permalink
[Reuters] Fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
hollowleviathan committed Jul 24, 2020
1 parent 64d38b5 commit 0e41636
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions bridges/ReutersBridge.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<?php
class ReutersBridge extends BridgeAbstract {


const MAINTAINER = 'hollowleviathan, spraynard, csisoap';
const NAME = 'Reuters Bridge';
const URI = 'https://reuters.com/';
const CACHE_TIMEOUT = 1800; // 30min
const DESCRIPTION = 'Returns news from Reuters';
private $feedName = self::NAME;


const ALLOWED_WIREITEM_TYPES = array(
'story'
);
Expand Down Expand Up @@ -39,7 +37,7 @@ class ReutersBridge extends BridgeAbstract {
'Lifestyle' => 'lifestyle',
'Markets' => 'markets',
'Sports' => 'sports',
'Pic of the Day' => 'pictures', //This have different configuration than others.
'Pic of the Day' => 'pictures', // This has a different configuration than the others.
'USA News' => 'us'
)
),
Expand All @@ -51,12 +49,10 @@ private function getJson($feedname) {
return json_decode($returned_data, true);
}


public function getName() {
return $this->feedName;
}


public function collectData() {
$feed = $this->getInput('feed');
$data = $this->getJson($feed);
Expand All @@ -65,30 +61,34 @@ public function collectData() {
/**
* Gets a list of wire items which are groups of templates
*/
$reuters_allowed_wireitems = array_filter($reuters_wireitems, function($wireitem) {
return in_array($wireitem['wireitem_type'], self::ALLOWED_WIREITEM_TYPES);
});
$reuters_allowed_wireitems = array_filter(
$reuters_wireitems, function ($wireitem) {
return in_array($wireitem['wireitem_type'], self::ALLOWED_WIREITEM_TYPES);
}
);

/**
* Gets a list of "Templates", which is data containing a story
*/
$reuters_wireitem_templates = array_reduce($reuters_allowed_wireitems, function (array $carry, array $wireitem) {
$wireitem_templates = $wireitem['templates'];
return array_merge($carry, array_filter($wireitem_templates, function(array $template_data) {
return in_array($template_data['type'], self::ALLOWED_TEMPLATE_TYPES);
}));
}, array());

$reuters_wireitem_templates = array_reduce(
$reuters_allowed_wireitems, function (array $carry, array $wireitem) {
$wireitem_templates = $wireitem['templates'];
return array_merge(
$carry, array_filter(
$wireitem_templates, function (array $template_data) {
return in_array($template_data['type'], self::ALLOWED_TEMPLATE_TYPES);
}
)
);
}, array()
);

// Check to see if there have Editor's Highlight sections in the first index.
if($reuters_wireitems[0]['wireitem_type'] == 'headlines') {
$top_highlight = $reuters_wireitems[0]["templates"][1]["headlines"];

$top_highlight = $reuters_wireitems[0]['templates'][1]['headlines'];
$reuters_wireitem_templates = array_merge($top_highlight, $reuters_wireitem_templates);
}



foreach ($reuters_wireitem_templates as $story) {
$item['content'] = $story['story']['lede'];
$item['title'] = $story['story']['hed'];
Expand Down

0 comments on commit 0e41636

Please sign in to comment.