1
0
Garpu 0
rss-bridge/bridges/IdenticaBridge.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 baris
1,2 KiB
PHP

<?php
class IdenticaBridge extends BridgeAbstract {
const MAINTAINER = 'mitsukarenai';
const NAME = 'Identica Bridge';
const URI = 'https://identi.ca/';
const CACHE_TIMEOUT = 300; // 5min
const DESCRIPTION = 'Returns user timelines';
const PARAMETERS = array( array(
'u' => array(
'name' => 'username',
'required' => true
)
));
public function collectData(){
$html = getSimpleHTMLDOM($this->getURI())
or returnServerError('Requested username can\'t be found.');
foreach($html->find('li.major') as $dent) {
$item = array();
// get dent link
$item['uri'] = html_entity_decode($dent->find('a', 0)->href);
// extract dent timestamp
$item['timestamp'] = strtotime($dent->find('abbr.easydate', 0)->plaintext);
// extract dent text
$item['content'] = trim($dent->find('div.activity-content', 0)->innertext);
$item['title'] = $this->getInput('u') . ' | ' . $item['content'];
$this->items[] = $item;
}
}
public function getName(){
if(!is_null($this->getInput('u'))) {
return $this->getInput('u') . ' - Identica Bridge';
}
return parent::getName();
}
public function getURI(){
if(!is_null($this->getInput('u'))) {
return self::URI . urlencode($this->getInput('u'));
}
return parent::getURI();
}
}