Rss-Bridge/bridges/MixCloudBridge.php
logmanoriginal a4b9611e66 [phpcs] Add missing rules
- Do not add spaces after opening or before closing parenthesis

  // Wrong
  if( !is_null($var) ) {
    ...
  }

  // Right
  if(!is_null($var)) {
    ...
  }

- Add space after closing parenthesis

  // Wrong
  if(true){
    ...
  }

  // Right
  if(true) {
    ...
  }

- Add body into new line
- Close body in new line

  // Wrong
  if(true) { ... }

  // Right
  if(true) {
    ...
  }

Notice: Spaces after keywords are not detected:

  // Wrong (not detected)
  // -> space after 'if' and missing space after 'else'
  if (true) {
    ...
  } else{
    ...
  }

  // Right
  if(true) {
    ...
  } else {
    ...
  }
2017-07-29 19:55:12 +02:00

52 lines
1.2 KiB
PHP

<?php
class MixCloudBridge extends BridgeAbstract {
const MAINTAINER = 'Alexis CHEMEL';
const NAME = 'MixCloud';
const URI = 'https://mixcloud.com/';
const CACHE_TIMEOUT = 3600; // 1h
const DESCRIPTION = 'Returns latest musics on user stream';
const PARAMETERS = array(array(
'u' => array(
'name' => 'username',
'required' => true,
)
));
public function getName(){
if(!is_null($this->getInput('u'))) {
return 'MixCloud - ' . $this->getInput('u');
}
return parent::getName();
}
public function collectData(){
$html = getSimpleHTMLDOM(self::URI . $this->getInput('u'))
or returnServerError('Could not request MixCloud.');
foreach($html->find('section.card') as $element) {
$item = array();
$item['uri'] = self::URI . $element->find('hgroup.card-title h1 a', 0)->getAttribute('href');
$item['title'] = html_entity_decode(
$element->find('hgroup.card-title h1 a span', 0)->getAttribute('title'),
ENT_QUOTES
);
$image = $element->find('a.album-art img', 0);
if($image) {
$item['content'] = '<img src="' . $image->getAttribute('src') . '" />';
}
$item['author'] = trim($element->find('hgroup.card-title h2 a', 0)->innertext);
$this->items[] = $item;
}
}
}