Method render
has 99 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function render() {
if (!$this->userObject instanceof User) {
throw new InvalidArgumentException("No valid user object has been provided");
}
Function render
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public function render() {
if (!$this->userObject instanceof User) {
throw new InvalidArgumentException("No valid user object has been provided");
}
- 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
The method render() has an NPath complexity of 28800. The configured NPath complexity threshold is 200. Open
public function render() {
if (!$this->userObject instanceof User) {
throw new InvalidArgumentException("No valid user object has been provided");
}
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method render() has 209 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public function render() {
if (!$this->userObject instanceof User) {
throw new InvalidArgumentException("No valid user object has been provided");
}
- Exclude checks
The method render() has a Cyclomatic Complexity of 20. The configured cyclomatic complexity threshold is 10. Open
public function render() {
if (!$this->userObject instanceof User) {
throw new InvalidArgumentException("No valid user object has been provided");
}
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The class Home has a coupling between objects value of 16. Consider to reduce the number of dependencies under 13. Open
class Home extends Prerender {
/**
* Render the page
* @since Version 3.10.0
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
Avoid assigning values to variables in if clauses and the like (line '92', column '8'). Open
public function render() {
if (!$this->userObject instanceof User) {
throw new InvalidArgumentException("No valid user object has been provided");
}
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Similar blocks of code found in 2 locations. Consider refactoring. Open
Debug::LogCLI("Template file " . $this->template . " is NOT cached for unique ID \"" . $this->unique . "\"");
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 30.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
$latest[$id]['topic_highlight'] = ColourUtility::String2Hex($latest[$id]['topic_title']);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 30.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
$latest[$id]['featured_image'] = ImageCache::cache($latest[$id]['featured_image']);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 30.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 7 locations. Consider refactoring. Open
$article['hometext'] = preg_replace("@(\[b\]|\[\/b\])@", "", $article['story_blurb']);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 28.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (count($Feed->filter_words) || count($Feed->filter_topics)) {
$latest = $Feed->findArticles(0, 20);
foreach ($latest as $id => $article) {
$article['sid'] = $article['story_id'];
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 24.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 5 locations. Consider refactoring. Open
$latest[$id]['url'] = $json['article']['source'];
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 23.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 5 locations. Consider refactoring. Open
$latest[$id]['url'] = $json['article']['url'];
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 23.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 5 locations. Consider refactoring. Open
$latest[$id]['staff'] = $json['article']['staff'];
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 23.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 5 locations. Consider refactoring. Open
$latest[$id]['author'] = $json['article']['author'];
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 23.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 5 locations. Consider refactoring. Open
$latest[$id]['topic'] = $json['article']['topic'];
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 23.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
$latest[$id]['hometext'] = isset($json['article']['blub']) ? wpautop(process_bbcode($json['article']['blub'])) : wpautop(process_bbcode($json['article']['blurb']));
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 23.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
$railcam['sizes']['small']['source'] = ImageCache::cache($railcam['sizes']['small']['source']);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 21.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
$this->smarty->Assign("alerts", $alerts, true);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 20.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
$this->smarty->Assign("jobs", $newjobs, true);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 20.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Blank line found at end of control structure Open
- Exclude checks
Blank line found at end of control structure Open
- Exclude checks
Function closing brace must go on the next line following the body; found 1 blank lines before brace Open
}
- Exclude checks
There must be one blank line after the last USE statement; 2 found; Open
use InvalidArgumentException;
- Exclude checks
Blank line found at start of control structure Open
if (!$upcoming = $Memcached->fetch($cachekey)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$upcoming = $Memcached->fetch($cachekey)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$upcoming[] = $data;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$Photo = $Camera->getLatest(false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$Feed = new Feed;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$article['topictext'] = $article['topic_title'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data['sid'] = $data['story_id'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
preg_match("/<p>(.*)<\/p>/", $latest[$id]['hometext'], $matches);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$upcoming = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Chronicle
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$Camera = new Camera(1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->smarty->Assign("railcam", $railcam);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$article['hometext'] = preg_replace("@(\[b\]|\[\/b\])@", "", $article['story_blurb']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$article['topic'] = $article['topic_id'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Load the JSON for this article
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$latest[$id]['topic'] = $json['article']['topic'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$Memcached = AppCore::GetMemcached();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$Events = new Events;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (filter_var($this->userObject->id, FILTER_VALIDATE_INT) && $this->userObject->id > 0) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$article['ForumThreadId'] = $article['forum_topic_id'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$newsLatest = array_shift($latest);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->params['handheld']) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$latest[$id]['hometext'] = isset($json['article']['blub']) ? wpautop(process_bbcode($json['article']['blub'])) : wpautop(process_bbcode($json['article']['blurb']));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$latest[$id]['topic_highlight'] = ColourUtility::String2Hex($latest[$id]['topic_title']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Pre-rendering
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$Memcached->save("railpage.home.upcomingevents", $upcoming, strtotime("+5 minutes"));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* New photos
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get the latest railcam photo
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$railcam = $Photo->getArray();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$Feed->setUser($this->userObject)->getFilters();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$article['sid'] = $article['story_id'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* No personal news feed - go ahead as normal
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Instantiate the base News module
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Format titles and tags for the latest news articles
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$latest[$id]['url'] = $json['article']['url'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$latest[$id]['author'] = $json['article']['author'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
//$Event = EventsFactory::CreateEvent($row['event_id']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$article['catid'] = $article['topic_id'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$article['title'] = $article['story_title'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$News = new Base;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->smarty->addHeadTag(sprintf("<link rel='prerender' href='%s'>", $json['article']['url']['url']));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->smarty->assign("newsLatest", $newsLatest);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (count($Feed->filter_words) || count($Feed->filter_topics)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$latest[$id] = $article;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset($data['sid'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Send them to Smarty
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->smarty->assign("news", $latest);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->smarty->isCached($this->template, $this->unique)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Upcoming events
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->smarty->Assign("newphotos", RecentImages::getNewest(5));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$article['informant_id'] = $article['user_id'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$article['featured_image'] = $article['story_image'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get the latest 15 news articles
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$cachekey = "railpage.home.upcomingevents";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$latest = $News->latest(20);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($Events->getUpcomingEvents(5) as $row) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$latest[$id]['hometext'] = strip_tags($matches[1]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$article['time_relative'] = time2str($article['story_time_unix']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$EventDate = new EventDate($row['id']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($json['article']['body']) && !empty($json['article']['source'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->smarty->Assign("chronicle", $Chronicle->getEntriesForToday(10));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($latest as $id => $data) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$latest = $Feed->findArticles(0, 20);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($latest as $id => $article) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$article['informant'] = $article['username'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->smarty->assign("pagecontrols", '<p style="background: #333; background: rgba(0, 0, 0, 0.6);margin: 0px -20px;padding: 0px;margin-top: 40px; text-align: center;font-size:1em;">Wasting time and bandwidth since 1992</p>');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data = $EventDate->getArray();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->smarty->Assign("upcomingevents", $upcoming);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$Chronicle = new Chronicle;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* First check if this user has a personalised news feed
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset($latest)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$latest[$id]['hometext'] = strip_tags($latest[$id]['hometext'], "<a><p><img><br><br /><strong><em>");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// Get the first paragraph from the home text
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->smarty->Assign("railcam_updated", ContentUtility::relativeTime($railcam['dates']['taken']));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->smarty->Assign("personalfeed", isset($latest));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$latest[$id]['staff'] = $json['article']['staff'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$json = json_decode(News::getArticleJSON($data['sid']), true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$latest[$id]['title'] = format_topictitle($data['title']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$latest[$id]['url'] = $json['article']['source'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Slice the first news article off
- Exclude checks