Skip to content

Commit

Permalink
Removing a useless dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier Lorenzana committed Nov 21, 2014
1 parent 511674b commit 6bce7c2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 51 deletions.
7 changes: 2 additions & 5 deletions Raml/DocParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@

namespace GoIntegro\Bundle\HateoasBundle\Raml;

// RAML.
use Raml\Parser;
// YAML.
use Symfony\Component\Yaml\Yaml;
// JSON.
use GoIntegro\Bundle\HateoasBundle\Util\JsonCoder;

class DocParser extends Parser
class DocParser
{
use DereferencesIncludes;

Expand Down Expand Up @@ -44,9 +42,8 @@ public function __construct(JsonCoder $jsonCoder)
*/
public function parse($filePath)
{
$apiDef = parent::parse($filePath);
$rawRaml = Yaml::parse($filePath);
$ramlDoc = new RamlDoc($apiDef, $rawRaml, $filePath);
$ramlDoc = new RamlDoc($rawRaml, $filePath);

if (isset($rawRaml['schemas'])) {
foreach ($rawRaml['schemas'] as $map) {
Expand Down
30 changes: 1 addition & 29 deletions Raml/RamlDoc.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

namespace GoIntegro\Bundle\HateoasBundle\Raml;

// RAML.
use Raml\ApiDefinition;

class RamlDoc
{
const HTTP_OPTIONS = 'options',
Expand Down Expand Up @@ -45,10 +42,6 @@ class RamlDoc
self::MEDIA_TYPE_JSON,
self::MEDIA_TYPE_XML
];
/**
* @var ApiDefinition
*/
public $apiDef;
/**
* @var array Read-only.
*/
Expand All @@ -67,15 +60,11 @@ class RamlDoc
private $schemaMaps = [];

/**
* @param $apiDef
* @param array $rawRaml
* @param string $fileName
*/
public function __construct(
ApiDefinition $apiDef, array $rawRaml, $fileName
)
public function __construct(array $rawRaml, $fileName)
{
$this->apiDef = $apiDef;
$this->rawRaml = $rawRaml;
$this->fileName = $fileName;
$this->fileDir = dirname($fileName);
Expand Down Expand Up @@ -120,21 +109,6 @@ public function getNamedSchema($name)
return NULL;
}

/**
* @param string $name
* @param array $args
*/
public function __call($name, $args)
{
$method = [$this->apiDef, $name];

if (is_callable($method)) {
return call_user_func_array($method, $args);
} else {
throw new \BadMethodCallException("No such method here.");
}
}

/**
* @param string $method
* @return boolean
Expand Down Expand Up @@ -193,8 +167,6 @@ public function isDefined($method, $path)
return isset($raml[$method]);
}



/**
* @param string $path
* @param integer $case
Expand Down
6 changes: 2 additions & 4 deletions Tests/Raml/RamlDocTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ class RamlDocTest extends TestCase
public function testCheckingWhetherRequestIsDefined()
{
/* Given... (Fixture) */
$apiDef = Stub::makeEmpty('Raml\ApiDefinition');
// Quite justifiable.
$rawRaml = Yaml::parse(__DIR__ . self::DEFAULT_SCHEMA_RAML);
$ramlDoc = new RamlDoc($apiDef, $rawRaml, self::DEFAULT_SCHEMA_RAML);
$ramlDoc = new RamlDoc($rawRaml, self::DEFAULT_SCHEMA_RAML);
/* When... (Action) */
$nay = $ramlDoc->isDefined(RamlDoc::HTTP_PUT, '/some-resources');
$yeah = $ramlDoc->isDefined(RamlDoc::HTTP_PUT, '/some-resources/1');
Expand All @@ -40,10 +39,9 @@ public function testCheckingWhetherRequestIsDefined()
public function testGettingAllowedMethodsForPath()
{
/* Given... (Fixture) */
$apiDef = Stub::makeEmpty('Raml\ApiDefinition');
// Quite justifiable.
$rawRaml = Yaml::parse(__DIR__ . self::DEFAULT_SCHEMA_RAML);
$ramlDoc = new RamlDoc($apiDef, $rawRaml, self::DEFAULT_SCHEMA_RAML);
$ramlDoc = new RamlDoc($rawRaml, self::DEFAULT_SCHEMA_RAML);
/* When... (Action) */
$allowedFiltered = $ramlDoc->getAllowedMethods('/some-resources');
$allowedById = $ramlDoc->getAllowedMethods('/some-resources/1');
Expand Down
14 changes: 1 addition & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,6 @@
"homepage": "http://www.gointegro.com"
}
],
"repositories": [
{
"type": "vcs",
"url": "https://github.com/skqr/php-raml-parser.git"
},
{
"type": "vcs",
"url": "https://github.com/skqr/ReverseRegex.git"
}
],
"require": {
"php": ">=5.4.0",
"symfony/framework-bundle": "*",
Expand All @@ -37,14 +27,12 @@
"doctrine/orm": "*",
"justinrainbow/json-schema": "*",
"rhumsaa/uuid": "*",
"skqr/php-raml-parser": "dev-master",
"predis/predis": "*"
},
"require-dev": {
"phpunit/phpunit": "*",
"phpdocumentor/phpdocumentor": "*",
"codeception/codeception": "*",
"skqr/reverse-regex": "dev-master"
"codeception/codeception": "*"
},
"autoload": {
"psr-0": { "GoIntegro\\Bundle\\HateoasBundle": "" }
Expand Down

0 comments on commit 6bce7c2

Please sign in to comment.