### Method naming examples Source: https://github.com/markrogoyski/math-php/wiki/Coding-Standards Examples of lowerCamelCase method naming, treating initialisms as words. ```text luDecomposition isRref pdf ``` -------------------------------- ### Aligned code example Source: https://github.com/markrogoyski/math-php/wiki/Coding-Standards Example of aligned code which is considered good practice for readability. ```php $x = 12; $x2 = 5; $sum = $x + $x2; ``` -------------------------------- ### Unaligned code example Source: https://github.com/markrogoyski/math-php/wiki/Coding-Standards Example of unaligned code which is considered bad practice. ```php $x = 12; $x2 = 5; $sum = $x + $x2; ``` -------------------------------- ### Unit test structure with data provider Source: https://github.com/markrogoyski/math-php/wiki/Coding-Standards Example of a unit test using the Given-When-Then pattern and a data provider for testing multiple inputs. ```php /** * @test add * @dataProvider dataProviderForAddition * @param float $a * @param float $b * @param float $expectedSum */ public function testAddition(float $a, float $b, float $expectedSum) { // Given $adder = new Adder(); // When $sum = $adder->add($a, $b); // Then $this->assertEquals($expectedSum, $sum); } /** * @return array [a, b, sum] */ public function dataProviderForAddition(): array { return [ [0, 1, 1], [1, 1, 2], [4, 8, 12], [55.4, 12.4, 67.8], // .. more test cases ]; } ``` -------------------------------- ### PHPDocBlock method documentation template Source: https://github.com/markrogoyski/math-php/wiki/Coding-Standards Standard template for documenting methods, including descriptions, formulas, parameters, return values, and exceptions. ```php /** * Method name * * Description of the method. * (link to citation) * * (Equation) * x = y * * @param int $x Description of parameter * @param int $y Description of parameter * * @return int * @throws Exception if x > b */ public function sum(int $x, int $y): int ``` -------------------------------- ### Project Directory Structure Source: https://github.com/markrogoyski/math-php/wiki/Contributing The standard directory layout for the Math PHP project, separating source code from unit tests. ```text src/ <- code goes here tests/ <- unit tests go here ``` -------------------------------- ### Matrix variable naming convention Source: https://github.com/markrogoyski/math-php/wiki/Coding-Standards Use common mathematical custom names like $A for a matrix when reasonable. ```php $A ``` -------------------------------- ### Logical code grouping Source: https://github.com/markrogoyski/math-php/wiki/Coding-Standards Organize related code into blocks separated by newlines to improve readability when the focus changes. ```php public function someFunction(int $a, int $b) { // Validate inputs (Validation block) if ($a < 0) { throw new \Exception('A must be >= 0'); } if ($b == 0) { throw new \Exception ('B must not == 0'); } // Use XYZ method to compute e (Computation block) $c = $a + b; $d = $c + $a + 9; $e = $c + d; // (Final block) return $e; } ``` -------------------------------- ### General variable naming convention Source: https://github.com/markrogoyski/math-php/wiki/Coding-Standards Use snake_case for general descriptive variable names. ```php $snake_case_with_underscores ``` -------------------------------- ### Variable naming preference for variance Source: https://github.com/markrogoyski/math-php/wiki/Coding-Standards Prefer concise mathematical symbols that match the equation being implemented over long descriptive names. ```text σ² = $∑⟮xᵢ − μ⟯² / $ν; ``` ```text $variance = $sum_of_squared_deviations_x_against_mean / $degrees_of_freedom; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.