Skip to content

Commit ea4df86

Browse files
committed
smaller simplications and use base CONSTANTS
1 parent 5a704be commit ea4df86

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

src/Factory.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use frictionlessdata\datapackage\Datapackages\BaseDatapackage;
66
use frictionlessdata\datapackage\Resources\BaseResource;
7+
use frictionlessdata\tableschema\SchemaValidationError;
78
use ZipArchive;
89

910
/**
@@ -39,9 +40,7 @@ public static function datapackage($source, $basePath = null)
3940
$descriptor = $source->descriptor;
4041
$basePath = $source->basePath;
4142
$datapackageClass = static::getDatapackageClass($descriptor);
42-
$datapackage = new $datapackageClass($descriptor, $basePath);
43-
44-
return $datapackage;
43+
return new $datapackageClass($descriptor, $basePath);
4544
}
4645

4746
/**
@@ -94,7 +93,7 @@ public static function validate($source, $basePath = null)
9493
// return a list containing a single LOAD_FAILED validation error
9594
return [
9695
new Validators\DatapackageValidationError(
97-
Validators\DatapackageValidationError::LOAD_FAILED,
96+
SchemaValidationError::LOAD_FAILED,
9897
$e->getMessage()
9998
),
10099
];
@@ -291,7 +290,7 @@ protected static function loadSource($source, $basePath)
291290
$basePath = null;
292291
}
293292
} else {
294-
// not a json string and not a url - assume it's a file path
293+
// not a json string and not an url - assume it's a file path
295294
if (static::isFileZipSource($source)) {
296295
return static::loadFileZipSource($source);
297296
} else {

0 commit comments

Comments
 (0)