3131 */
3232class File extends Processor
3333{
34- private $ dir = '' ;
35- private $ ext = '' ;
34+ private string $ dir = '' ;
35+ private string $ ext = '' ;
3636
3737 /**
3838 * {@inheritdoc}
@@ -41,15 +41,15 @@ public function __construct(array $settings)
4141 {
4242 parent ::__construct ($ settings );
4343
44- umask (umask () | 0002 );
44+ \ umask (\ umask () | 0002 );
4545 $ this ->ext = (string )($ settings ['extension ' ] ?? '.log ' );
46- $ this ->dir = rtrim ((string )$ settings ['dir ' ], '/ ' );
46+ $ this ->dir = \ rtrim ((string )$ settings ['dir ' ], '/ ' );
4747
48- if (false === is_dir ($ this ->dir )) {
48+ if (false === \ is_dir ($ this ->dir )) {
4949 throw FileProcessorException::directoryDoesNotExist ($ this ->dir );
5050 }
5151
52- if (false === is_writable ($ this ->dir )) {
52+ if (false === \ is_writable ($ this ->dir )) {
5353 throw FileProcessorException::directoryIsNotWritable ($ this ->dir );
5454 }
5555
@@ -60,10 +60,10 @@ protected function process(array $message): void
6060 {
6161 try {
6262 // The filename should be calculated at the moment of writing
63- $ dir = $ this ->dir . date ('Y/m ' );
64- is_dir ($ dir ) || mkdir ($ dir , 0775 , true );
63+ $ dir = $ this ->dir . \ date ('Y/m ' );
64+ \ is_dir ($ dir ) || \ mkdir ($ dir , 0775 , true );
6565
66- file_put_contents ($ dir . '/ ' . date ('d ' ) . $ this ->ext , strtr ($ this ->format , $ message ) . PHP_EOL ,
66+ \ file_put_contents ($ dir . '/ ' . \ date ('d ' ) . $ this ->ext , \ strtr ($ this ->format , $ message ) . PHP_EOL ,
6767 FILE_APPEND );
6868
6969 // @codeCoverageIgnoreStart
@@ -78,20 +78,21 @@ protected function process(array $message): void
7878class FileProcessorException extends KodedException
7979{
8080 private const
81- E_DIRECTORY_DOES_NOT_EXIST = 1 , E_DIRECTORY_NOT_WRITABLE = 2 ;
81+ E_DIRECTORY_DOES_NOT_EXIST = 1 ,
82+ E_DIRECTORY_NOT_WRITABLE = 2 ;
8283
83- protected $ messages = [
84+ protected array $ messages = [
8485 self ::E_DIRECTORY_DOES_NOT_EXIST => 'Log directory ":dir" must exist ' ,
8586 self ::E_DIRECTORY_NOT_WRITABLE => 'Log directory ":dir" must be writable ' ,
8687 ];
8788
88- public static function directoryDoesNotExist (string $ directory ): self
89+ public static function directoryDoesNotExist (string $ directory ): static
8990 {
90- return new self ( self ::E_DIRECTORY_DOES_NOT_EXIST , [':dir ' => $ directory ]);
91+ return new static ( static ::E_DIRECTORY_DOES_NOT_EXIST , [':dir ' => $ directory ]);
9192 }
9293
93- public static function directoryIsNotWritable (string $ directory ): self
94+ public static function directoryIsNotWritable (string $ directory ): static
9495 {
95- return new self ( self ::E_DIRECTORY_NOT_WRITABLE , [':dir ' => $ directory ]);
96+ return new static ( static ::E_DIRECTORY_NOT_WRITABLE , [':dir ' => $ directory ]);
9697 }
9798}
0 commit comments