File xpdotransport.class.php
has 503 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*
* Copyright 2010-2015 by MODX, LLC.
*
* This file is part of xPDO.
xPDOTransport
has 27 functions (exceeds 20 allowed). Consider refactoring. Open
class xPDOTransport {
/**#@+
* Attributes of the package that can be used to control behavior.
* @var string
*/
Function _pack
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public static function _pack(& $xpdo, $filename, $path, $source) {
$packed = false;
$packResults = false;
$errors = array();
if ($xpdo->getOption(xPDOTransport::ARCHIVE_WITH, null, 0) != xPDOTransport::ARCHIVE_WITH_PCLZIP && class_exists('ZipArchive', true) && $xpdo->loadClass('compression.xPDOZip', XPDO_CORE_PATH, true, true)) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function install
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public function install($options= array ()) {
$installed= false;
$saved = array();
$this->_preserved = array();
if (!is_array($options)) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function retrieve
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public static function retrieve(& $xpdo, $source, $target, $state= xPDOTransport::STATE_PACKED) {
$instance= null;
$signature = basename($source, '.transport.zip');
if (file_exists($source)) {
if (is_writable($target)) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method satisfies
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function satisfies($version, $constraint) {
$satisfied = false;
$constraint = trim($constraint);
if (substr($constraint, 0, 1) === '~') {
$requirement = substr($constraint, 1);
Function uninstall
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function uninstall($options = array ()) {
$processed = array();
if (!is_array($options)) {
$options= array(xPDOTransport::PACKAGE_ACTION => xPDOTransport::ACTION_UNINSTALL);
} elseif (!isset($options[xPDOTransport::PACKAGE_ACTION])) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method retrieve
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function retrieve(& $xpdo, $source, $target, $state= xPDOTransport::STATE_PACKED) {
$instance= null;
$signature = basename($source, '.transport.zip');
if (file_exists($source)) {
if (is_writable($target)) {
Function satisfies
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public static function satisfies($version, $constraint) {
$satisfied = false;
$constraint = trim($constraint);
if (substr($constraint, 0, 1) === '~') {
$requirement = substr($constraint, 1);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method _pack
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function _pack(& $xpdo, $filename, $path, $source) {
$packed = false;
$packResults = false;
$errors = array();
if ($xpdo->getOption(xPDOTransport::ARCHIVE_WITH, null, 0) != xPDOTransport::ARCHIVE_WITH_PCLZIP && class_exists('ZipArchive', true) && $xpdo->loadClass('compression.xPDOZip', XPDO_CORE_PATH, true, true)) {
Function put
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function put($artifact, $attributes = array ()) {
$added= false;
if (!empty($artifact)) {
$vehiclePackage = isset($attributes['vehicle_package']) ? $attributes['vehicle_package'] : '';
$vehiclePackagePath = isset($attributes['vehicle_package_path']) ? $attributes['vehicle_package_path'] : '';
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method install
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function install($options= array ()) {
$installed= false;
$saved = array();
$this->_preserved = array();
if (!is_array($options)) {
Function get
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function get($objFile, $options= array ()) {
$vehicle = null;
$objFile = $this->path . $this->signature . '/' . $objFile;
$vehiclePackage = isset($options['vehicle_package']) ? $options['vehicle_package'] : '';
$vehiclePackagePath = isset($options['vehicle_package_path']) ? $options['vehicle_package_path'] : '';
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function writeManifest
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function writeManifest() {
$written = false;
if (!empty ($this->vehicles)) {
if (!empty($this->attributes['setup-options']) && is_array($this->attributes['setup-options'])) {
$cacheManager = $this->xpdo->getCacheManager();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function parseSignature
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function parseSignature($signature) {
$exploded = explode('-', $signature);
$name = current($exploded);
$version = '';
$part = next($exploded);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function checkPlatformDependencies
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function checkPlatformDependencies($dependencies) {
if (is_array($dependencies)) {
foreach ($dependencies as $depName => $depRequire) {
switch ($depName) {
case 'php':
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _unpack
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function _unpack(& $xpdo, $from, $to) {
$resources = false;
if ($xpdo->getOption(xPDOTransport::ARCHIVE_WITH, null, 0) != xPDOTransport::ARCHIVE_WITH_PCLZIP && class_exists('ZipArchive', true) && $xpdo->loadClass('compression.xPDOZip', XPDO_CORE_PATH, true, true)) {
$archive = new xPDOZip($xpdo, $from);
if ($archive) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function writePreserved
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function writePreserved() {
$written = false;
if (!empty($this->_preserved)) {
$content = var_export($this->_preserved, true);
$cacheManager = $this->xpdo->getCacheManager();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function unpack
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function unpack(& $xpdo, $from, $to, $state = xPDOTransport::STATE_PACKED) {
$manifest= null;
if ($state !== xPDOTransport::STATE_UNPACKED) {
$resources = xPDOTransport::_unpack($xpdo, $from, $to);
} else {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _convertManifestVer1_0
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected static function _convertManifestVer1_0($manifestVehicles) {
$manifest = array();
foreach ($manifestVehicles as $vClass => $vehicles) {
foreach ($vehicles as $vKey => $vehicle) {
$entry = array(
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"