File MediumSpecificBagOStuff.php
has 586 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Storage medium specific cache for storing items.
*
* This program is free software; you can redistribute it and/or modify
MediumSpecificBagOStuff
has 51 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class MediumSpecificBagOStuff extends BagOStuff {
/** @var array<string,array> Map of (key => (class LOCK_* constant => value) */
protected $locks = [];
/** @var int Bytes; chunk size of segmented cache values */
protected $segmentationSize;
Method updateOpStats
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function updateOpStats( string $op, array $keyInfo ) {
$deltasByMetric = [];
foreach ( $keyInfo as $indexOrKey => $keyOrSizes ) {
if ( is_array( $keyOrSizes ) ) {
Function updateOpStats
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
protected function updateOpStats( string $op, array $keyInfo ) {
$deltasByMetric = [];
foreach ( $keyInfo as $indexOrKey => $keyOrSizes ) {
if ( is_array( $keyOrSizes ) ) {
- 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 mergeViaCas
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
final protected function mergeViaCas( $key, callable $callback, $exptime, $attempts, $flags ) {
$attemptsLeft = $attempts;
do {
$token = self::PASS_BY_REF;
// Get the old value and CAS token from cache
Method makeValueOrSegmentList
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
final protected function makeValueOrSegmentList( $key, $value, $exptime, $flags, &$ok ) {
$entry = $value;
$ok = true;
if ( $this->useSegmentationWrapper( $value, $flags ) ) {
Function mergeViaCas
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
final protected function mergeViaCas( $key, callable $callback, $exptime, $attempts, $flags ) {
$attemptsLeft = $attempts;
do {
$token = self::PASS_BY_REF;
// Get the old value and CAS token from cache
- 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 useSegmentationWrapper
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function useSegmentationWrapper( $value, $flags ) {
if (
$this->segmentationSize === INF ||
!$this->fieldHasFlags( $flags, self::WRITE_ALLOW_SEGMENTS )
) {
- 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 doLock
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function doLock( $key, $timeout, $exptime ) {
$lockTsUnix = null;
$fname = __METHOD__;
$loop = new WaitConditionLoop(
Function unlock
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function unlock( $key ) {
$released = false;
if ( isset( $this->locks[$key] ) ) {
if ( --$this->locks[$key][self::LOCK_DEPTH] > 0 ) {
- 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 merge
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function merge( $key, callable $callback, $exptime = 0, $attempts = 10, $flags = 0 ) {
Method mergeViaCas
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
final protected function mergeViaCas( $key, callable $callback, $exptime, $attempts, $flags ) {
Method cas
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function cas( $casToken, $key, $value, $exptime = 0, $flags = 0 ) {
Method makeValueOrSegmentList
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
final protected function makeValueOrSegmentList( $key, $value, $exptime, $flags, &$ok ) {
Method doIncrWithInit
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
abstract protected function doIncrWithInit( $key, $exptime, $step, $init, $flags );
Method doCas
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function doCas( $casToken, $key, $value, $exptime = 0, $flags = 0 ) {
Method incrWithInit
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function incrWithInit( $key, $exptime, $step = 1, $init = null, $flags = 0 ) {
Function resolveSegments
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
final protected function resolveSegments( $key, $mainValue ) {
if ( SerializedValueContainer::isSegmented( $mainValue ) ) {
$orderedKeys = array_map(
function ( $segmentHash ) use ( $key ) {
return $this->makeGlobalKey( self::SEGMENT_COMPONENT, $key, $segmentHash );
- 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 checkIterableMapSerializability
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function checkIterableMapSerializability( $value, $key ) {
foreach ( $value as $index => $entry ) {
if ( is_object( $entry ) ) {
// Note that Closure instances count as objects
if (
- 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 makeValueOrSegmentList
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
final protected function makeValueOrSegmentList( $key, $value, $exptime, $flags, &$ok ) {
$entry = $value;
$ok = true;
if ( $this->useSegmentationWrapper( $value, $flags ) ) {
- 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 doChangeTTL
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function doChangeTTL( $key, $exptime, $flags ) {
// @TODO: the use of lock() assumes that all other relevant sets() use a lock
if ( !$this->lock( $key, 0 ) ) {
return false;
}
- 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 lock
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function lock( $key, $timeout = 6, $exptime = 6, $rclass = '' ) {
$exptime = min( $exptime ?: INF, self::TTL_DAY );
$acquired = false;
- 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
Avoid too many return
statements within this method. Open
return $this->deleteMulti( $orderedKeys, $flags & ~self::WRITE_PRUNE_SEGMENTS );
Function getMulti
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getMulti( array $keys, $flags = 0 ) {
$foundByKey = $this->doGetMulti( $keys, $flags );
$res = [];
foreach ( $keys as $key ) {
- 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"