Completed
Push — master ( 196a0a...af77e8 )
by Zack
11:10 queued 04:43
created

Collection::count()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 11 and the first side effect is on line 5.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
namespace GV;
3
4
/** If this file is called directly, abort. */
5
if ( ! defined( 'GRAVITYVIEW_DIR' ) )
0 ignored issues
show
Coding Style Best Practice introduced by
It is generally a best practice to always use braces with control structures.

Adding braces to control structures avoids accidental mistakes as your code changes:

// Without braces (not recommended)
if (true)
    doSomething();

// Recommended
if (true) {
    doSomething();
}
Loading history...
6
	die();
7
8
/**
9
 * A generic Collection base class.
10
 */
11
class Collection {
12
	/**
13
	 * @var array Main storage for objects in this collection.
14
	 */
15
	private $storage = array();
16
17
	/**
18
	 * Add an object to this collection.
19
	 *
20
	 * @param mixed $value The object to be added.
21
	 *
22
	 * @api
23
	 * @since future
24
	 * @return void
25
	 */
26
	public function append( $value ) {
27
		$this->storage []= $value;
0 ignored issues
show
introduced by
Expected 1 space before "="; 0 found
Loading history...
28
	}
29
30
	/**
31
	 * Returns all the objects in this collection as an an array.
32
	 *
33
	 * @api
34
	 * @since future
35
	 * @return array The objects in this collection.
36
	 */
37
	public function all() {
38
		return $this->storage;
39
	}
40
41
	/**
42
	 * Returns the count of the objects in this collection.
43
	 *
44
	 * @api
45
	 * @since future
46
	 * @return int The size of this collection.
47
	 */
48
	public function count() {
49
		return count( $this->storage );
50
	}
51
}
52