Ejemplo n.º 1
0
 /**
  * Delivers stored and derived employee data
  *
  * @return array
  */
 public function get()
 {
     /** @var \Tune\Repository\PDO\Employees $resource */
     $resource = $this->repository->getEmployees();
     /** START makeTree */
     \Tune\StatsD::client()->startMemoryProfile('makeTree');
     \Tune\StatsD::client()->startTiming('makeTree');
     while ($row = $resource->fetch()) {
         $this->makeTree($row);
     }
     \Tune\StatsD::client()->endTiming('makeTree');
     \Tune\StatsD::client()->endMemoryProfile('makeTree');
     /** END makeTree */
     /** START countTree */
     \Tune\StatsD::client()->startMemoryProfile('countTree');
     \Tune\StatsD::client()->startTiming('countTree');
     $this->countTree($this->tree);
     \Tune\StatsD::client()->endTiming('countTree');
     \Tune\StatsD::client()->endMemoryProfile('countTree');
     /** END countTree */
     /** START treeDepthOutput */
     \Tune\StatsD::client()->startMemoryProfile('treeDepthOutput');
     \Tune\StatsD::client()->startTiming('treeDepthOutput');
     $this->treeDepthOutput(1, $this->tree[1]);
     \Tune\StatsD::client()->endTiming('treeDepthOutput');
     \Tune\StatsD::client()->endMemoryProfile('treeDepthOutput');
     /** END treeDepthOutput */
     return $this->output;
 }
Ejemplo n.º 2
0
 public function setup()
 {
     $this->repositoryMock = m::mock('Tune\\Repository\\EmployeesInterface');
     $this->repositoryData = json_decode(file_get_contents(__DIR__ . "/EmployeesTestData.json"), true);
     $statsdMock = m::mock('\\Domnikl\\StatsD\\Client')->shouldIgnoreMissing();
     StatsD::$client = $statsdMock;
     $inputArray = new \ArrayIterator($this->repositoryData['input']);
     $resourceMock = m::mock('Tune\\Repository\\AdapterInterface');
     $iteration = function () use($inputArray) {
         if ($inputArray->valid()) {
             $response = $inputArray->current();
             $inputArray->next();
         }
         return isset($response) ? $response : false;
     };
     $resourceMock->shouldReceive('fetch')->times(21)->andReturnUsing($iteration);
     $this->repositoryMock->shouldReceive('getEmployees')->once()->andReturn($resourceMock);
 }
Ejemplo n.º 3
0
<?php

$autoload_file = "../vendor/autoload.php";
if (!file_exists($autoload_file)) {
    throw new \Exception('fatal: Unable to load dependencies. (pro-tip: `README.md`)');
}
$config_file = "../config.json";
if (!file_exists($config_file)) {
    throw new \Exception('fatal: Unable to load config.json. ¯\\_(ツ)_/¯');
}
require_once $autoload_file;
$statsd = new \Tune\StatsD();
$statsd->connect();
\Tune\StatsD::client()->startTiming('execution');
$config = new \Tune\Config();
$config->load($config_file);
$router = new \Tune\Router(new \Slim\Slim());
$router->routes()->run();
\Tune\StatsD::client()->memory('execution');
\Tune\StatsD::client()->endTiming('execution');