/** * @param $elementHtml */ public function __construct($elementHtml) { $this->id = Helpers\RegExp::getFirstMatch(Config::get('maltapark.idForListItem'), $elementHtml); $this->img_url = Helpers\RegExp::getFirstMatch(Config::get('maltapark.imgForListItem'), $elementHtml); $this->title = strip_tags(Helpers\RegExp::getFirstMatch(Config::get('maltapark.titleForListItem'), $elementHtml)); $this->price = Helpers\RegExp::getFirstMatch(Config::get('maltapark.priceForListItem'), $elementHtml); $this->price_val = Helpers\TextFormatter::currencyStringToFloat($this->price); $this->date = Helpers\RegExp::getFirstMatch(Config::get('maltapark.dateForListItem'), $elementHtml); }
protected function performChecks() { $token = $this->request->getHeader(Config::get('app.authHeader')); if (empty($token)) { throw new UnAuthorizedException('Missing Header'); } $this->userId = UserToken::getValidUserId($token, $this->request->getAttribute('ip_address')); if (empty($this->userId)) { // Log attempt then remove token? throw new UnAuthorizedException('Unauthorized'); } }
/** * @param $elementHtml * @param $itemId */ public function __construct($elementHtml, $itemId) { $this->id = $itemId; $this->img_url = Config::get('maltapark.detailImgUrl'); $this->img_url .= Helpers\RegExp::getFirstMatch(Config::get('maltapark.imgForItemDetail'), $elementHtml); $this->title = strip_tags(Helpers\RegExp::getFirstMatch(Config::get('maltapark.titleForItemDetail'), $elementHtml)); $this->price = Helpers\RegExp::getFirstMatch(Config::get('maltapark.priceForItemDetail'), $elementHtml); $this->price_val = Helpers\TextFormatter::currencyStringToFloat($this->price); $this->contact = Config::get('maltapark.contactImgUrl'); $this->contact .= Helpers\RegExp::getFirstMatch(Config::get('maltapark.contactForItemDetail'), $elementHtml); $this->description = strip_tags(Helpers\RegExp::getFirstMatch(Config::get('maltapark.descriptionForItemDetail'), $elementHtml)); foreach ($this->topDetailsLabel as $lblKey => $lblRegex) { $this->{$lblKey} = Helpers\RegExp::getFirstMatch($lblRegex . Config::get('maltapark.topDetailForItemDetail'), $elementHtml); } }
/** * @group Roles * @group config */ public function testCorrectDisplayModuleDescriptionRole() { $modules = \App\Lib\Helpers\Config::get('modules.modules'); $this->assertNotEmpty($modules); $roles = \App\Lib\Helpers\Config::get('modules.roles'); $rolesKeys = array_keys($roles); foreach ($modules as $key => $module) { $this->assertNotEmpty($module["roles"]); foreach ($module["roles"] as $index => $playNum) { if ($playNum != 0) { $this->assertGreaterThan(0, $playNum); $this->assertNotNull($roles[$rolesKeys[$index]]["description"]); } } } }
/** * @param string $query * @param int $pageNum * @return array */ public static function searchFromNet($query = "", $pageNum = 1) { if (empty($query)) { return []; } $url = Config::get('maltapark.url') . Config::get('maltapark.pageSearch') . $query . Config::get('maltapark.pageNum') . $pageNum; $content = Helpers\FakeBrowser::get($url); $items = []; $crawler = new Crawler(null, $url); $crawler->addContent($content, "text/html"); foreach ($crawler->filter('#item_list') as $node) { $item = new ListItem(Helpers\Dom::getHtml($node)); $items[] = $item; } return $items; }
/** * @param Team $team * @return Player */ private function pickAScorer(Team $team) { $player = null; if (Randomizer::boolOnPercentage(70)) { $roles = Config::get('modules.roles'); $forwards = array_splice($roles, count($roles) / 2); $pos = array_rand($forwards); unset($forwards[$pos]); $player = $team->getBestPlayerForRole($pos); while (empty($player)) { if (!empty($forwards)) { $pos = array_rand($forwards); unset($forwards[$pos]); $player = $team->getBestPlayerForRole($pos); } else { $player = $team->roster[array_rand($team->roster)]; } } } else { $player = $team->roster[array_rand($team->roster)]; } return $player; }
/** * @return mixed */ public function getLocale() { $locales = Config::get('generic.localesSmall'); shuffle($locales); return $locales[0]; }
/** * @param int $pageNum * @return string */ public static function getJobs($pageNum = 1) { return FakeBrowser::get(Config::get('keepmeposted.url') . Config::get('keepmeposted.jobsApi') . Config::get('keepmeposted.pageNum') . $pageNum . Config::get('keepmeposted.fixedCategories')); }
/** * @param bool $complete * @return array */ public function getRoleNeeded($complete = false) { $rolesNeeded = []; $roles = \App\Lib\Helpers\Config::get('modules.roles'); $rolesKeys = array_keys($roles); foreach ($this->configuration["roles"] as $index => $playNum) { if ($playNum != 0 || $complete) { $rolesNeeded[$rolesKeys[$index]] = $playNum; } } return $rolesNeeded; }
<?php require_once "vendor/autoload.php"; use App\Lib\Helpers\Config; use App\Lib\Helpers\RouteLoader; use Slim\App; use Slim\Container; $api = new App(new Container(Config::get('app.boot'))); // Here you can add all the middleware $api->add(new RKA\Middleware\IpAddress()); $api->add(new \CorsSlim\CorsSlim()); $routes = RouteLoader::load(); foreach ($routes as $route) { require_once $route; } $api->run();
/** * @group Module */ public function testModule() { $rndF = new \App\Lib\DsManager\Helpers\RandomFiller("it_IT"); $team = $rndF->getTeam(); $modules = \App\Lib\Helpers\Config::get("modules.modules"); $modules = array_keys($modules); foreach ($modules as $mod) { $module = new \App\Lib\DsManager\Models\Module($mod); $this->assertNotEmpty($module); $this->assertNotNull($module->isDefensive()); $this->assertNotNull($module->isBalanced()); $this->assertNotNull($module->isOffensive()); $this->assertTrue(is_array($module->getRoleNeeded())); } $this->assertGreaterThan(0, $team->playersPerRoleArray()); }