Exemplo n.º 1
0
 /**
  * Replaces the `~` symbol with the user home path.
  *
  * @param string $path
  * @return string The path with the `~` replaced with the user home path if any.
  */
 public static function homeify($path, SystemLocals $locals = null)
 {
     if (!is_string($path)) {
         throw new \InvalidArgumentException('Paht must be a string');
     }
     if (empty($locals)) {
         $locals = new SystemLocals();
     }
     $userHome = $locals->home();
     if (!(empty($userHome) && false !== strpos($path, '~'))) {
         $path = str_replace('~', $userHome, $path);
     }
     return $path;
 }
Exemplo n.º 2
0
 /**
  * @test
  * it should return replaced home symbol
  * @dataProvider homeSymbolPahts
  */
 public function it_should_return_replaced_home_symbol($path, $expected)
 {
     $locals = new SystemLocals();
     $locals->setHome('/foo/bar');
     $this->assertEquals($expected, PathUtils::homeify($path, $locals));
 }