@@ -30,14 +30,14 @@ class PhpDevServe
3030 *
3131 * @var string
3232 */
33- public $ phpBin = self ::PHP_BIN ;
33+ protected $ phpBin = self ::PHP_BIN ;
3434
3535 /**
3636 * The document root dir for server
3737 *
3838 * @var string
3939 */
40- public $ docRoot = './ ' ;
40+ protected $ docRoot = './ ' ;
4141
4242 /**
4343 * The entry file for server. e.g web/index.php
@@ -107,14 +107,14 @@ public static function findPhpBin(): string
107107 * Class constructor.
108108 *
109109 * @param string $serveAddr
110- * @param string $documentRoot
110+ * @param string $docRoot
111111 * @param string $entryFile
112112 */
113- public function __construct (string $ serveAddr , string $ documentRoot , string $ entryFile = '' )
113+ public function __construct (string $ serveAddr , string $ docRoot , string $ entryFile = '' )
114114 {
115- $ this ->docRoot = $ documentRoot ;
116- $ this ->entryFile = $ entryFile ;
117115 $ this ->serveAddr = $ serveAddr ?: self ::SVR_ADDR ;
116+ $ this ->setDocRoot ($ docRoot );
117+ $ this ->setEntryFile ($ entryFile );
118118 }
119119
120120 /**
@@ -323,4 +323,32 @@ public function setEntryFile(string $entryFile): self
323323 $ this ->entryFile = $ entryFile ;
324324 return $ this ;
325325 }
326+
327+ /**
328+ * @param string $phpBin
329+ *
330+ * @return PhpDevServe
331+ */
332+ public function setPhpBin (string $ phpBin ): self
333+ {
334+ if ($ phpBin ) {
335+ $ this ->phpBin = $ phpBin ;
336+ }
337+
338+ return $ this ;
339+ }
340+
341+ /**
342+ * @param string $docRoot
343+ *
344+ * @return PhpDevServe
345+ */
346+ public function setDocRoot (string $ docRoot ): self
347+ {
348+ if ($ docRoot ) {
349+ $ this ->docRoot = $ docRoot ;
350+ }
351+
352+ return $ this ;
353+ }
326354}
0 commit comments