RecommendationService
in package
Table of Contents
Properties
- $calculators : array<string, CalculatorInterface>
- Registered recommendation calculators
- $logger : LoggerInterface
Methods
- __construct() : mixed
- Constructor with dependency injection
- clearModelRecommendationCache() : void
- Clear cache for a specific model instance
- clearRecommendationCache() : void
- Clear cache for a specific recommendation set
- generateRecommendations() : int
- Generate recommendations for all models of a specific class
- generateRecommendationsForModel() : int
- Generate recommendations for a specific model instance
- getAvailableAlgorithms() : array<string|int, mixed>
- Get available algorithms
- getCalculator() : CalculatorInterface
- Get calculator for an algorithm
- getRecommendations() : Collection
- Get recommendations for a model with optional caching
- registerCalculator() : $this
- Register a calculator for a specific algorithm
- fetchRecommendations() : Collection
- Fetch recommendations from the database
- saveRecommendations() : int
- Save calculated recommendations to the database
Properties
$calculators
Registered recommendation calculators
private
array<string, CalculatorInterface>
$calculators
= []
$logger
private
LoggerInterface
$logger
Methods
__construct()
Constructor with dependency injection
public
__construct(LoggerInterface $logger) : mixed
Parameters
- $logger : LoggerInterface
clearModelRecommendationCache()
Clear cache for a specific model instance
public
clearModelRecommendationCache(Model $model, string $name) : void
Parameters
- $model : Model
- $name : string
clearRecommendationCache()
Clear cache for a specific recommendation set
public
clearRecommendationCache(string $modelClass, string $name) : void
Parameters
- $modelClass : string
- $name : string
generateRecommendations()
Generate recommendations for all models of a specific class
public
generateRecommendations(string $modelClass, string $name[, array<string|int, mixed> $options = [] ]) : int
Parameters
- $modelClass : string
- $name : string
- $options : array<string|int, mixed> = []
-
Additional options for generation
Return values
intgenerateRecommendationsForModel()
Generate recommendations for a specific model instance
public
generateRecommendationsForModel(Model $model, string $name) : int
Parameters
- $model : Model
- $name : string
Return values
intgetAvailableAlgorithms()
Get available algorithms
public
getAvailableAlgorithms() : array<string|int, mixed>
Return values
array<string|int, mixed>getCalculator()
Get calculator for an algorithm
public
getCalculator(string $algorithm) : CalculatorInterface
Parameters
- $algorithm : string
Tags
Return values
CalculatorInterfacegetRecommendations()
Get recommendations for a model with optional caching
public
getRecommendations(Model $model, string $name[, bool $refresh = false ]) : Collection
Parameters
- $model : Model
- $name : string
- $refresh : bool = false
-
Force refresh even when cache is enabled
Return values
CollectionregisterCalculator()
Register a calculator for a specific algorithm
public
registerCalculator(string $algorithm, CalculatorInterface $calculator) : $this
Parameters
- $algorithm : string
- $calculator : CalculatorInterface
Return values
$thisfetchRecommendations()
Fetch recommendations from the database
private
fetchRecommendations(Model $model, string $name) : Collection
Parameters
- $model : Model
- $name : string
Return values
CollectionsaveRecommendations()
Save calculated recommendations to the database
private
saveRecommendations(string $modelClass, string $name, array<string|int, mixed> $recommendations, array<string|int, mixed> $config, array<string|int, mixed> $options) : int
Parameters
- $modelClass : string
- $name : string
- $recommendations : array<string|int, mixed>
- $config : array<string|int, mixed>
- $options : array<string|int, mixed>