File LBFactory.php
has 477 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
LBFactory
has 42 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class LBFactory implements ILBFactory {
/** @var CriticalSectionProvider|null */
private $csProvider;
/**
* @var callable|null An optional callback that returns a ScopedCallback instance,
Function waitForReplication
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function waitForReplication( array $opts = [] ) {
$opts += [
'timeout' => $this->replicationWaitTimeout,
'ifWritesSince' => null
];
- 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 waitForReplication
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function waitForReplication( array $opts = [] ) {
$opts += [
'timeout' => $this->replicationWaitTimeout,
'ifWritesSince' => null
];
Method configure
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function configure( array $conf ): void {
$this->localDomain = isset( $conf['localDomain'] )
? DatabaseDomain::newFromId( $conf['localDomain'] )
: DatabaseDomain::newUnspecified();
Method commitPrimaryChanges
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
final public function commitPrimaryChanges( $fname = __METHOD__, int $maxWriteDuration = 0 ) {
$this->assertTransactionRoundStage( self::ROUND_CURSORY );
/** @noinspection PhpUnusedLocalVariableInspection */
$scope = ScopedCallback::newScopedIgnoreUserAbort();
Function getMappedDatabase
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function getMappedDatabase( $index, $groups, $domain ) {
if ( $domain !== false && in_array( $domain, $this->virtualDomains ) ) {
if ( isset( $this->virtualDomainsMapping[$domain] ) ) {
$config = $this->virtualDomainsMapping[$domain];
if ( isset( $config['cluster'] ) ) {
- 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 commitPrimaryChanges
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
final public function commitPrimaryChanges( $fname = __METHOD__, int $maxWriteDuration = 0 ) {
$this->assertTransactionRoundStage( self::ROUND_CURSORY );
/** @noinspection PhpUnusedLocalVariableInspection */
$scope = ScopedCallback::newScopedIgnoreUserAbort();
- 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 shutdown
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function shutdown(
$flags = self::SHUTDOWN_NORMAL,
callable $workCallback = null,
&$cpIndex = null,
&$cpClientId = null
- 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 logIfMultiDbTransaction
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function logIfMultiDbTransaction() {
$callersByDB = [];
foreach ( $this->getLBsForOwner() as $lb ) {
$primaryName = $lb->getServerName( $lb->getWriterIndex() );
$callers = $lb->pendingPrimaryChangeCallers();
- 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"