本文整理汇总了PHP中Strings::removespaces方法的典型用法代码示例。如果您正苦于以下问题:PHP Strings::removespaces方法的具体用法?PHP Strings::removespaces怎么用?PHP Strings::removespaces使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Strings
的用法示例。
在下文中一共展示了Strings::removespaces方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
public function process(array $documents, &$context)
{
$document = $documents[self::URL_PROFILE];
$documentMobile = $documents[self::URL_PROFILE_MOBILE];
$dom = self::getDOM($document);
$domMobile = self::getDOM($documentMobile);
$xpath = new DOMXPath($dom);
$xpathMobile = new DOMXPath($domMobile);
if ($xpath->query('//h1[text() = \'404 Not Found\']')->length >= 1) {
throw new BadProcessorKeyException($context->key);
}
$name = Strings::removeSpaces(self::getNodeValue($xpath, '//h1//span'));
$name = substr($name, 0, strpos($name, '\'s Profile'));
$name = Strings::removeSpaces($name);
if (empty($name)) {
throw new BadProcessorDocumentException($document, 'Username missing');
}
$image = self::getNodeValue($xpath, '//div[contains(@class, \'user-image\')]//img', null, 'src');
$joinDate = Strings::makeDate(self::getNodeValue($xpath, '//span[text() = \'Joined\']/following-sibling::span'));
$malId = Strings::makeInteger(self::getNodeValue($xpath, '//input[@name = \'profileMemId\']', null, 'value'));
$postCount = Strings::makeInteger(self::getNodeValue($xpath, '//a[@href=\'https://myanimelist.net/forum/index.php?action=search&u=' . $name . '&q=&uloc=1&loc=-1\']/span[2]'));
$birthday = Strings::makeDate(self::getNodeValue($xpath, '//span[text() = \'Birthday\']/following-sibling::span'));
$location = Strings::removespaces(self::getNodeValue($xpath, '//span[text() = \'Location\']/following-sibling::span'));
$websiteNode = $xpath->query('//h4[text() = \'Also Available at\']/following-sibling::div/a/@href');
if ($websiteNode->length >= 1) {
$website = $xpath->query('//h4[text() = \'Also Available at\']/following-sibling::div/a/@href')->item(0)->nodeValue;
} else {
$website = "";
}
$gender = Strings::makeEnum(self::getNodeValue($xpath, '//span[text() = \'Gender\']/following-sibling::span'), ['Female' => UserGender::Female, 'Male' => UserGender::Male], UserGender::Unknown);
$animeViewCount = Strings::makeInteger(self::getNodeValue($xpathMobile, '//td[text() = \'Anime List Views\']/following-sibling::td'));
$mangaViewCount = Strings::makeInteger(self::getNodeValue($xpathMobile, '//td[text() = \'Manga List Views\']/following-sibling::td'));
$user =& $context->user;
$user->name = $name;
$user->picture_url = $image;
$user->join_date = $joinDate;
$user->mal_id = $malId;
$user->posts = $postCount;
$user->birthday = $birthday;
$user->location = $location;
$user->website = $website;
$user->gender = $gender;
$user->anime_views = $animeViewCount;
$user->manga_views = $mangaViewCount;
$user->processed = date('Y-m-d H:i:s');
R::store($user);
}
示例2: process
public function process(array $documents, &$context)
{
$doc = $documents[self::URL_PROFILE];
$dom = self::getDOM($doc);
$xpath = new DOMXPath($dom);
if ($xpath->query('//title[text() = \'Invalid User\']')->length >= 1) {
throw new BadProcessorKeyException($context->key);
}
$userName = Strings::removeSpaces(self::getNodeValue($xpath, '//title'));
$userName = substr($userName, 0, strpos($userName, '\'s Profile'));
$userName = str_replace('Top - ', '', $userName);
$userName = Strings::removeSpaces($userName);
if (empty($userName)) {
throw new BadProcessorDocumentException($doc, 'User name missing');
}
$pictureUrl = self::getNodeValue($xpath, '//td[@class = \'profile_leftcell\']//img', null, 'src');
$joinDate = Strings::makeDate(self::getNodeValue($xpath, '//td[text() = \'Join Date\']/following-sibling::td'));
$malId = Strings::makeInteger(self::getNodeValue($xpath, '//input[@name = \'profileMemId\']', null, 'value'));
$animeViewCount = Strings::makeInteger(self::getNodeValue($xpath, '//td[text() = \'Anime List Views\']/following-sibling::td'));
$mangaViewCount = Strings::makeInteger(self::getNodeValue($xpath, '//td[text() = \'Manga List Views\']/following-sibling::td'));
$commentCount = Strings::makeInteger(self::getNodeValue($xpath, '//td[text() = \'Comments\']/following-sibling::td'));
$postCount = Strings::makeInteger(self::getNodeValue($xpath, '//td[text() = \'Forum Posts\']/following-sibling::td'));
$birthday = Strings::makeDate(self::getNodeValue($xpath, '//td[text() = \'Birthday\']/following-sibling::td'));
$location = Strings::removespaces(self::getNodeValue($xpath, '//td[text() = \'Location\']/following-sibling::td'));
$website = Strings::removeSpaces(self::getNodeValue($xpath, '//td[text() = \'Website\']/following-sibling::td'));
$gender = Strings::makeEnum(self::getNodeValue($xpath, '//td[text() = \'Gender\']/following-sibling::td'), ['Female' => UserGender::Female, 'Male' => UserGender::Male], UserGender::Unknown);
$user =& $context->user;
$user->name = $userName;
$user->picture_url = $pictureUrl;
$user->join_date = $joinDate;
$user->mal_id = $malId;
$user->comments = $commentCount;
$user->posts = $postCount;
$user->birthday = $birthday;
$user->location = $location;
$user->website = $website;
$user->gender = $gender;
$user->anime_views = $animeViewCount;
$user->manga_views = $mangaViewCount;
$user->processed = date('Y-m-d H:i:s');
R::store($user);
}