Ejemplo n.º 1
0
 private function readConfiguration(InputInterface $input, OutputInterface $output)
 {
     $path = getcwd() . DIRECTORY_SEPARATOR . 'resolver-builder.json';
     if (!is_file($path) || !is_readable($path)) {
         $output->writeln(sprintf('<error>Missing configuration file "%s".</error>', $path));
         return null;
     }
     $data = file_get_contents($path);
     $config = json_decode($data, true);
     if (!$config) {
         $output->writeln(sprintf('<error>The file "%s" contains errors.</error>', $path));
         return null;
     }
     if (!array_key_exists('output', $config)) {
         $output->writeln('<error>Missing "output" configuration option.</error>');
         return null;
     }
     if (!array_key_exists('target', $config['output'])) {
         $output->writeln('<error>Missing "target" configuration option in output configuration.</error>');
         return null;
     }
     $homepage = new Uri($config['homepage']);
     if (!$homepage->isAbsolute() || $homepage->isSchemeless()) {
         $output->writeln(sprintf('<error>The homepage "%s" is invalid.</error>', $config['homepage']));
         return null;
     }
     $outputTarget = new Uri($config['output']['target']);
     if ($outputTarget->isRelative()) {
         $config['output']['target'] = getcwd() . '/' . ltrim($config['output']['target'], '/');
     }
     return $config;
 }
Ejemplo n.º 2
0
 public function testIsSchemeless()
 {
     $uri = new Uri();
     $uri->setAbsolute();
     $this->assertSame(true, $uri->isSchemeless());
     $uri->setRelative();
     $this->assertSame(true, $uri->isSchemeless());
     $uri->setAbsolute();
     $this->assertSame('//', $uri->getUri());
     $uri->setScheme('http');
     $this->assertSame(false, $uri->isSchemeless());
     $this->assertSame('http://', $uri->getUri());
     $uri->setRelative();
     $this->assertSame(true, $uri->isSchemeless());
     $this->assertSame('', $uri->getUri());
 }