77 *
88 * @package drupol\phpermutations
99 */
10- abstract class Combinatorics implements \Countable {
10+ abstract class Combinatorics implements \Countable
11+ {
1112
1213 /**
1314 * The dataset.
1415 *
1516 * @var array
1617 */
17- protected $ dataset ;
18+ protected $ dataset ;
1819
1920 /**
2021 * The number of values in the dataset.
2122 *
2223 * @var int
2324 */
24- protected $ datasetCount ;
25+ protected $ datasetCount ;
2526
2627 /**
2728 * The length.
2829 *
2930 * @var int
3031 */
31- protected $ length ;
32+ protected $ length ;
3233
3334 /**
3435 * Combinatorics constructor.
@@ -38,11 +39,12 @@ abstract class Combinatorics implements \Countable {
3839 * @param int|null $length
3940 * The length.
4041 */
41- public function __construct (array $ dataset = array (), $ length = NULL ) {
42- $ this ->setDataset ($ dataset );
43- $ this ->datasetCount = count ($ this ->dataset );
44- $ this ->setLength ($ length );
45- }
42+ public function __construct (array $ dataset = array (), $ length = null )
43+ {
44+ $ this ->setDataset ($ dataset );
45+ $ this ->datasetCount = count ($ this ->dataset );
46+ $ this ->setLength ($ length );
47+ }
4648
4749 /**
4850 * Set the length.
@@ -52,22 +54,24 @@ public function __construct(array $dataset = array(), $length = NULL) {
5254 *
5355 * @return $this
5456 */
55- public function setLength ($ length = NULL ) {
56- $ length = is_null ($ length ) ? $ this ->datasetCount : $ length ;
57- $ this ->length = ($ length > $ this ->datasetCount ) ? $ this ->datasetCount : $ length ;
57+ public function setLength ($ length = null )
58+ {
59+ $ length = is_null ($ length ) ? $ this ->datasetCount : $ length ;
60+ $ this ->length = ($ length > $ this ->datasetCount ) ? $ this ->datasetCount : $ length ;
5861
59- return $ this ;
60- }
62+ return $ this ;
63+ }
6164
6265 /**
6366 * Get the length.
6467 *
6568 * @return int
6669 * The length.
6770 */
68- public function getLength () {
69- return (int ) $ this ->length ;
70- }
71+ public function getLength ()
72+ {
73+ return (int ) $ this ->length ;
74+ }
7175
7276 /**
7377 * Set the dataset.
@@ -77,21 +81,23 @@ public function getLength() {
7781 *
7882 * @return $this
7983 */
80- public function setDataset (array $ dataset = array ()) {
81- $ this ->dataset = $ dataset ;
84+ public function setDataset (array $ dataset = array ())
85+ {
86+ $ this ->dataset = $ dataset ;
8287
83- return $ this ;
84- }
88+ return $ this ;
89+ }
8590
8691 /**
8792 * Get the dataset.
8893 *
8994 * @return mixed[]
9095 * The dataset.
9196 */
92- public function getDataset () {
93- return $ this ->dataset ;
94- }
97+ public function getDataset ()
98+ {
99+ return $ this ->dataset ;
100+ }
95101
96102 /**
97103 * Compute the factorial of an integer.
@@ -104,8 +110,8 @@ public function getDataset() {
104110 * @return int
105111 * The factorial of $n.
106112 */
107- protected function fact ($ n , $ total = 1 ) {
108- return ( $ n < 2 ) ? $ total : $ this -> fact ( $ n - 1 , $ total * $ n );
109- }
110-
113+ protected function fact ($ n , $ total = 1 )
114+ {
115+ return ( $ n < 2 ) ? $ total : $ this -> fact ( $ n - 1 , $ total * $ n );
116+ }
111117}
0 commit comments