@@ -55,7 +55,7 @@ public function sanitize(string $filename): string
5555 */
5656 private function isFileSafe (string $ filename , string $ envVariable ): bool
5757 {
58- $ safeFile = $ this ->getParameter ($ envVariable );
58+ $ safeFile = $ this ->getParam ($ envVariable );
5959
6060
6161 if ($ safeFile !== $ filename ) {
@@ -69,31 +69,32 @@ private function isFileSafe(string $filename, string $envVariable): bool
6969 * @param string $filename
7070 * @param string $envVariable
7171 * @return bool
72+ * @throws FileHandlerException
7273 */
7374 public function isFileRestricted (string $ filename , string $ envVariable ): bool
7475 {
7576 return $ this ->isFileSafe ($ filename , $ envVariable );
7677 }
7778
7879 /**
79- * @param string $param
80- * @return string
81- * @throws FileHandlerException
80+ * @return ContainerBuilder
8281 */
83- private function getParameter ( string $ param ): string
82+ private function getContainerBuilder ( ): ContainerBuilder
8483 {
85- $ container = (new ServiceContainer ())->getContainerBuilder ();
86- return $ this ->getParam ($ container , $ param );
84+ return (new ServiceContainer ())->getContainerBuilder ();
8785 }
8886
8987 /**
90- * @param ContainerBuilder $container
9188 * @param string $parameter
89+ * @param ContainerBuilder|null $container
9290 * @return string
9391 * @throws FileHandlerException
9492 */
95- public function getParam (ContainerBuilder $ container , string $ parameter ): string
93+ public function getParam (string $ parameter , ContainerBuilder $ container = null ): string
9694 {
95+ if (null === $ container ) {
96+ $ container = $ this ->getContainerBuilder ();
97+ }
9798 $ param = $ container ->getParameter ($ parameter );
9899 if (!is_string ($ param )) {
99100 throw new FileHandlerException ("{$ parameter } is not string type " );
0 commit comments