Skip to content

Commit

Permalink
MSS-151: Simplify version handling a bit more by using a constant for…
Browse files Browse the repository at this point in the history
… the current version
  • Loading branch information
cyberwolf committed May 7, 2015
1 parent d4f5c23 commit 60d9d86
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions lib/CultureFeed/Cdb/Default.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
class CultureFeed_Cdb_Default {

/**
* Url to the cdb xml scheme.
* Url to the latest cdb xml scheme.
*/
const CDB_SCHEME_URL = 'http://www.cultuurdatabank.com/XMLSchema/CdbXSD/3.3/FINAL';

/**
* Version of the latest cdb xml scheme.
*/
const CDB_SCHEME_VERSION = '3.3';

/**
* Name from the xml scheme.
*/
Expand Down Expand Up @@ -43,22 +48,18 @@ class CultureFeed_Cdb_Default {
*/
public function __construct($cdb_schema_version = null) {

$pattern = '/(\d.\d)/';

if (isset($cdb_schema_version)) {

$this->cdb_schema_version = $cdb_schema_version;
$this->cdb_schema_url = preg_replace($pattern, $cdb_schema_version, self::CDB_SCHEME_URL);
$this->cdb_schema_url = str_replace(
self::CDB_SCHEME_VERSION,
$cdb_schema_version,
self::CDB_SCHEME_URL
);

} else {

$matches = array();
preg_match($pattern, self::CDB_SCHEME_URL, $matches);
$this->cdb_schema_version = $matches[1];
$this->cdb_schema_version = self::CDB_SCHEME_VERSION;
$this->cdb_schema_url = self::CDB_SCHEME_URL;

}

}

/**
Expand Down

0 comments on commit 60d9d86

Please sign in to comment.