/** * Parse API Docs */ protected function parseDocuments() { $this->apis = array(3 => Api::build('Meetup', 3, 'Meetup API v3 methods'), 2 => Api::build('Meetup', 2, 'Meetup API v2 methods'), 1 => Api::build('Meetup', 1, 'Meetup API v1 methods'), 'stream' => Api::build('Meetup', 'stream', 'Meetup API Stream methods')); $this->output->writeln('Downloading data from API docs ...'); $data = $this->getApiData(); /** @var TableHelper $nameConversionTable */ $nameConversionTable = $this->getHelper('table'); $nameConversionTable->setHeaders(array('v', 'Docs Name', 'Method', 'Path', 'Final Method Name')); $this->output->writeln('Parsing data from API docs ...'); foreach ($data['docs'] as $definition) { $operation = Operation::createFromApiJsonDocs($definition); if ($operation === null) { continue; } $nameConversionTable->addRow(array($operation->version, arr::get('name', $definition), arr::get('http_method', $definition), arr::get('path', $definition), $operation->name)); $this->apis[$operation->version]->addOperation($operation); } if ($this->input->getOption('debug-names')) { $nameConversionTable->render($this->output); } }
/** * @param $definition * @return static */ public static function createFromApiJsonDocs($definition) { if (arr::get('group', $definition) == 'deprecated') { return null; } $operation = new static(); $operation->version = arr::get('group', $definition) == 'streams' ? 'stream' : arr::get('api_version', $definition, '1'); $operation->httpMethod = arr::get('http_method', $definition); $operation->summary = arr::get('desc', $definition); $operation->notes = arr::get('param_notes', $definition); $operation->parsePath(arr::get('path', $definition)); foreach (arr::get('params', $definition, array()) as $param => $desc) { // Always false due to complex rules on meetup's side (one of x is required) $operation->addParameter(str_replace('*', '', $param), 'query', false, $desc); } foreach (arr::get('orders', $definition, array()) as $param => $desc) { $operation->addParameter($param, 'query', false, $desc); } $operation->addStandardParameters(arr::get('http_method', $definition)); $operation->name = OperationNameConverter::parseOperationName($operation); return $operation; }
public function testItRegisterAliasOnlyOnce() { $this->assertTrue(ArrayPath::registerClassAlias('AP')); $this->assertFalse(ArrayPath::registerClassAlias('AP')); }
/** * Check if the actual value matches the expected. * Actual passed by reference to preserve reference trail (where applicable) * back to the original method parameter. * * @param mixed $actual * @return bool */ public function match(&$actual) { return A::exists($actual, $this->path) && A::get($actual, $this->path) == $this->_expected; }