<?php header("Content-type: text/html;charset=utf8"); // define system constants define('BASE_PATH', __DIR__); define('APP_PATH', BASE_PATH . '/app'); define('SERVER_NAME', '/test-livetex/'); // PDO CONNECTION DETAILS define('DB_HOST', 'localhost'); define('DB_NAME', 'html_parser'); define('DB_USER', 'user'); define('DB_PASS', 'password'); // use namespace autoloader $autoloader = (include_once BASE_PATH . "/vendor/autoload.php"); $autoloader->add('', APP_PATH); $autoloader->add('Controller', APP_PATH); $autoloader->add('Model', APP_PATH); $app = new App(); $app->execute();
foreach ($factorsMultiplier as $primeNumber => $count) { if (isset($factorsDivider[$primeNumber])) { $factorsDivider[$primeNumber] -= $count; } else { $factorsDivider[$primeNumber] = -$count; } } } private function isEnoughFactors($factorsDivider) { foreach ($factorsDivider as $primeNumber => $count) { if ($count > 0) { return false; } } return true; } private function isPrimeNumber($number) { return in_array($number, $this->factor->getPrimeNumbers()); } } $primeNumbersFinder = new PrimeNumberFinder(); $factor = new Factor($primeNumbersFinder); $app = new App($factor); $testCases = [['input' => [1, 1], 'output' => true], ['input' => [1, 2], 'output' => false], ['input' => [2, 1], 'output' => true], ['input' => [6, 10], 'output' => true], ['input' => [13, 25], 'output' => true], ['input' => [13, 13], 'output' => true], ['input' => [13, 20], 'output' => true], ['input' => [13, 17], 'output' => false], ['input' => [34, 137], 'output' => false], ['input' => [100000, 99971], 'output' => true], ['input' => [105000, 99970], 'output' => true]]; foreach ($testCases as $case) { if ($app->execute($case['input'][0], $case['input'][1]) !== $case['output']) { throw new \Exception(sprintf("fail with input params %s, %s", $case['input'][0], $case['input'][1])); } }
<?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); define("_AIKIDO", ''); function __autoload($class_name) { include $class_name . '.php'; } if (!isset($_GET['page'])) { $_GET['page'] = "logout"; } try { $application = new App(); $application->execute(); } catch (Exception $e) { header('location: index.php?page=exception&message=' . $e->getMessage()); } catch (PDOException $e) { header('location: index.php?page=exception&message=' . $e->getMessage()); }
<?php App::execute(); //! Abstract class for application plugins abstract class Plugin { /** * Return plugin instance * @return static **/ public static function instance() { static $instance = null; if (null === $instance) { $instance = new static(); } return $instance; } /** * Handle plugin initialization * @return NULL **/ public function init($fw) { } protected function __construct() { } private function __clone() { }