template fixes + bug fixes + style fixes

This commit is contained in:
Dennis Eichhorn 2024-04-02 21:40:48 +00:00
parent 61f44bc044
commit ab3e8e0939
14 changed files with 56 additions and 48 deletions

View File

@ -226,37 +226,22 @@ class TrueSkill
/ (NormalDistribution::getCdf($epsilon - $tAbs, 0.0, 1.0) - NormalDistribution::getCdf(-$epsilon - $tAbs, 0.0, 1.0));
}
/**
*
*/
private function buildRatingLayer() : void
{
}
/**
*
*/
private function buildPerformanceLayer() : void
{
}
/**
*
*/
private function buildTeamPerformanceLayer() : void
{
}
/**
*
*/
private function buildTruncLayer() : void
{
}
/**
*
*/
private function factorGraphBuilders()
{
// Rating layer
@ -275,9 +260,6 @@ class TrueSkill
];
}
/**
*
*/
public function rating() : void
{
// Start values

View File

@ -40,9 +40,9 @@ final class BayesianPersonalizedRanking
/**
* Constructor.
*
* @param int $numFactors Determines the dimensionality of the latent factor space.
* @param float $learningRate Controls the step size for updating the latent factors during optimization.
* @param float $regularization Prevents over-fitting by adding a penalty for large parameter values.
* @param int $numFactors determines the dimensionality of the latent factor space
* @param float $learningRate controls the step size for updating the latent factors during optimization
* @param float $regularization prevents over-fitting by adding a penalty for large parameter values
*
* @since 1.0.0
*/

View File

@ -1336,4 +1336,17 @@ final class ReadMapper extends DataMapperAbstract
}
}
}
public function paginate(string $member, string $ptype, mixed $offset) : self
{
if ($ptype === 'p') {
$this->where($member, $offset ?? 0, '<');
} elseif ($ptype === 'n') {
$this->where($member, $offset ?? 0, '>');
} else {
$this->where($member, 0, '>');
}
return $this;
}
}

View File

@ -228,6 +228,12 @@ final class UriFactory
);
*/
// @feature Implement whitelisting/blacklisting for {?}
// Currently it copies all parameters
// Ideally you could use
// {?+para1,para2} for whitelisting
// {?-para1,para2} for blacklisting
if (\stripos($url, '?') === false && ($pos = \stripos($url, '&')) !== false) {
$url = \substr_replace($url, '?', $pos, 1);
}

View File

@ -57,6 +57,10 @@ abstract class TwoDAbstract extends CodeAbstract
*/
protected function createImage(array $codeArray) : mixed
{
if (empty($codeArray)) {
return null;
}
$dimensions = $this->calculateDimensions($codeArray);
$image = \imagecreate($dimensions['width'], $dimensions['height']);
@ -115,6 +119,13 @@ abstract class TwoDAbstract extends CodeAbstract
*/
private function calculateDimensions(array $codeArray) : array
{
if (empty($codeArray)) {
return [
'width' => 0,
'height' => 0,
];
}
$matrixDimension = \max(\count($codeArray), \count(\reset($codeArray)));
$imageDimension = \max($this->dimension['width'], $this->dimension['width']);

View File

@ -288,7 +288,7 @@ final class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase
public function testGetAll() : void
{
BaseModelMapper::create()->execute($this->model);
self::assertCount(1, BaseModelMapper::getAll()->execute());
self::assertCount(1, BaseModelMapper::getAll()->executeGetArray());
}
public function testGetYield() : void
@ -303,7 +303,7 @@ final class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase
public function testGetFor() : void
{
$id = BaseModelMapper::create()->execute($this->model);
$for = ManyToManyDirectModelMapper::getAll()->where('to', $id)->execute();
$for = ManyToManyDirectModelMapper::getAll()->where('to', $id)->executeGetArray();
self::assertEquals(
\reset($this->model->hasManyDirect)->string,
@ -337,7 +337,7 @@ final class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase
$model2->datetime = new \DateTime('now');
$id2 = BaseModelMapper::create()->execute($model2);
$newest = BaseModelMapper::getAll()->sort('id', OrderType::DESC)->limit(1)->execute();
$newest = BaseModelMapper::getAll()->sort('id', OrderType::DESC)->limit(1)->executeGetArray();
self::assertEquals($id2, \reset($newest)->id);
}
@ -393,7 +393,7 @@ final class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase
BaseModelMapper::create()->execute($model2);
BaseModelMapper::create()->execute($model3);
$found = BaseModelMapper::getAll()->where('string', '%sir%' , 'LIKE')->execute();
$found = BaseModelMapper::getAll()->where('string', '%sir%' , 'LIKE')->executeGetArray();
self::assertCount(2, $found);
self::assertEquals($model2->string, \reset($found)->string);
self::assertEquals($model3->string, \end($found)->string);
@ -455,7 +455,7 @@ final class DataMapperAbstractTest extends \PHPUnit\Framework\TestCase
$cond3->base = $id2;
ConditionalMapper::create()->execute($cond3);
$found = BaseModelMapper::getAll()->with('conditional')->where('conditional/language', 'de')->execute();
$found = BaseModelMapper::getAll()->with('conditional')->where('conditional/language', 'de')->executeGetArray();
self::assertCount(2, $found);
self::assertEquals($model1->string, \reset($found)->string);
self::assertEquals($model2->string, \end($found)->string);

View File

@ -407,7 +407,7 @@ final class ModuleAbstractTest extends \PHPUnit\Framework\TestCase
$this->dbSetup();
$this->module->create();
self::assertCount(1, BaseModelMapper::getAll()->execute());
self::assertCount(1, BaseModelMapper::getAll()->executeGetArray());
$this->dbTeardown();
}
@ -419,7 +419,7 @@ final class ModuleAbstractTest extends \PHPUnit\Framework\TestCase
$this->dbSetup();
$this->module->createMultiple();
self::assertCount(2, BaseModelMapper::getAll()->execute());
self::assertCount(2, BaseModelMapper::getAll()->executeGetArray());
$this->dbTeardown();
}
@ -447,7 +447,7 @@ final class ModuleAbstractTest extends \PHPUnit\Framework\TestCase
$this->module->create();
self::assertCount(1, BaseModelMapper::getAll()->execute());
$this->module->delete();
self::assertCount(0, BaseModelMapper::getAll()->execute());
self::assertCount(0, BaseModelMapper::getAll()->executeGetArray());
$this->dbTeardown();
}

View File

@ -15,7 +15,6 @@ declare(strict_types=1);
namespace phpOMS\tests\Stdlib\Base;
use phpOMS\Stdlib\Base\Address;
use phpOMS\Stdlib\Base\Location;
/**
* @internal

View File

@ -115,7 +115,6 @@ final class NodeTest extends \PHPUnit\Framework\TestCase
}
/**
*
* @bug Directed graphs may return invalid neighbors
* https://github.com/Karaka-Management/phpOMS/issues/366
*/

View File

@ -234,7 +234,6 @@ final class ArrayUtilsTest extends \PHPUnit\Framework\TestCase
self::assertNull(ArrayUtils::getArg('--testNull', $_SERVER['argv'] ?? []));
}
#[\PHPUnit\Framework\Attributes\Group('framework')]
#[\PHPUnit\Framework\Attributes\TestDox('All array values in an array can be potentiated by a numeric value')]
public function test() : void

View File

@ -32,7 +32,6 @@ final class ScheduleTest extends \PHPUnit\Framework\TestCase
self::assertInstanceOf('\phpOMS\Utils\TaskSchedule\TaskAbstract', $job);
}
#[\PHPUnit\Framework\Attributes\Group('framework')]
#[\PHPUnit\Framework\Attributes\TestDox('A task can be created from an array and rendered')]
public function testCreateJobWithData() : void