@@ -27,7 +27,18 @@ public function __construct(
2727 */
2828 public function getEmbeddingModels (): array
2929 {
30- return (array )$ this ->configResolver ->getParameter ('embedding_models ' );
30+ $ models = $ this ->configResolver ->getParameter ('embedding_models ' );
31+
32+ if (!is_array ($ models )) {
33+ throw new InvalidArgumentException (
34+ sprintf (
35+ 'Config parameter "embedding_models" must be an array, %s given. ' ,
36+ get_debug_type ($ models )
37+ )
38+ );
39+ }
40+
41+ return $ models ;
3142 }
3243
3344 /**
@@ -56,7 +67,18 @@ public function getEmbeddingModel(string $identifier): array
5667
5768 public function getDefaultEmbeddingModelIdentifier (): string
5869 {
59- return (string )$ this ->configResolver ->getParameter ('default_embedding_model ' );
70+ $ identifier = $ this ->configResolver ->getParameter ('default_embedding_model ' );
71+
72+ if (!is_string ($ identifier )) {
73+ throw new InvalidArgumentException (
74+ sprintf (
75+ 'Config parameter "default_embedding_model" must be a string, %s given. ' ,
76+ get_debug_type ($ identifier )
77+ )
78+ );
79+ }
80+
81+ return $ identifier ;
6082 }
6183
6284 /**
@@ -71,11 +93,33 @@ public function getDefaultEmbeddingModel(): array
7193
7294 public function getDefaultEmbeddingProvider (): string
7395 {
74- return (string )$ this ->getDefaultEmbeddingModel ()['embedding_provider ' ];
96+ $ provider = $ this ->getDefaultEmbeddingModel ()['embedding_provider ' ];
97+
98+ if (!is_string ($ provider )) {
99+ throw new InvalidArgumentException (
100+ sprintf (
101+ 'Default embedding model must define a string "embedding_provider", %s given. ' ,
102+ get_debug_type ($ provider )
103+ )
104+ );
105+ }
106+
107+ return $ provider ;
75108 }
76109
77110 public function getDefaultEmbeddingModelFieldSuffix (): string
78111 {
79- return (string )$ this ->getDefaultEmbeddingModel ()['field_suffix ' ];
112+ $ fieldSuffix = $ this ->getDefaultEmbeddingModel ()['field_suffix ' ];
113+
114+ if (!is_string ($ fieldSuffix )) {
115+ throw new InvalidArgumentException (
116+ sprintf (
117+ 'Default embedding model must define a string "field_suffix", %s given. ' ,
118+ get_debug_type ($ fieldSuffix )
119+ )
120+ );
121+ }
122+
123+ return $ fieldSuffix ;
80124 }
81125}
0 commit comments