original_string: public function isIn($directory, $cwd = null)
  	{
  		$dir = Path::info($directory);
  		if ($dir->isEmpty()) {
  			throw new \InvalidArgumentException('Directory is empty.');
  		}
  		$dir = $dir->normalize()->assumeDirectory();
  		$self = $this->normalize();
  		
  		if (! $dir->isAbsolute() && is_null($cwd)) {
  			throw new \InvalidArgumentException(sprintf('Directory "%s" is not absolute, you have to provide a working directory.', $directory));
  		}
  		if (! $self->isAbsolute() && is_null($cwd)) {
  			throw new \InvalidArgumentException(sprintf('Path "%s" is not absolute, you have to provide a working directory.', $this));
  		}
  		if (! is_null($cwd)) {
  			$cwd = Path::info($cwd)->normalize()->assumeDirectory();
  			if (! $cwd->isAbsolute()) {
  				throw new \InvalidArgumentException(sprintf('Working directory "%s" must be absolute.', $cwd));
  			}
  			if ($cwd->isEmpty()) {
  				throw new \InvalidArgumentException('Working directory is empty.');
  			}
  			$dir = $dir->abs($cwd);
  			$self = $self->abs($cwd);
  		}
  		
  		if (strpos($self->__toString(), $dir->__toString()) === 0) {
  			return true;
  		}
  		return false;
  	}
code: public function isIn($directory, $cwd = null)
  	{
  		$dir = Path::info($directory);
  		if ($dir->isEmpty()) {
  			throw new \InvalidArgumentException('Directory is empty.');
  		}
  		$dir = $dir->normalize()->assumeDirectory();
  		$self = $this->normalize();
  		
  		if (! $dir->isAbsolute() && is_null($cwd)) {
  			throw new \InvalidArgumentException(sprintf('Directory "%s" is not absolute, you have to provide a working directory.', $directory));
  		}
  		if (! $self->isAbsolute() && is_null($cwd)) {
  			throw new \InvalidArgumentException(sprintf('Path "%s" is not absolute, you have to provide a working directory.', $this));
  		}
  		if (! is_null($cwd)) {
  			$cwd = Path::info($cwd)->normalize()->assumeDirectory();
  			if (! $cwd->isAbsolute()) {
  				throw new \InvalidArgumentException(sprintf('Working directory "%s" must be absolute.', $cwd));
  			}
  			if ($cwd->isEmpty()) {
  				throw new \InvalidArgumentException('Working directory is empty.');
  			}
  			$dir = $dir->abs($cwd);
  			$self = $self->abs($cwd);
  		}
  		
  		if (strpos($self->__toString(), $dir->__toString()) === 0) {
  			return true;
  		}
  		return false;
  	}
code_tokens: public function isIn ( $ directory , $ cwd = null ) { $ dir = Path :: info ( $ directory ) ; if ( $ dir -> isEmpty ( ) ) { throw new \ InvalidArgumentException ( 'Directory is empty.' ) ; } $ dir = $ dir -> normalize ( ) -> assumeDirectory ( ) ; $ self = $ this -> normalize ( ) ; if ( ! $ dir -> isAbsolute ( ) && is_null ( $ cwd ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Directory "%s" is not absolute, you have to provide a working directory.' , $ directory ) ) ; } if ( ! $ self -> isAbsolute ( ) && is_null ( $ cwd ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Path "%s" is not absolute, you have to provide a working directory.' , $ this ) ) ; } if ( ! is_null ( $ cwd ) ) { $ cwd = Path :: info ( $ cwd ) -> normalize ( ) -> assumeDirectory ( ) ; if ( ! $ cwd -> isAbsolute ( ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Working directory "%s" must be absolute.' , $ cwd ) ) ; } if ( $ cwd -> isEmpty ( ) ) { throw new \ InvalidArgumentException ( 'Working directory is empty.' ) ; } $ dir = $ dir -> abs ( $ cwd ) ; $ self = $ self -> abs ( $ cwd ) ; } if ( strpos ( $ self -> __toString ( ) , $ dir -> __toString ( ) ) === 0 ) { return true ; } return false ; }
docstring: Tests whether the path is within the given directory.
  
  @param string|Path $directory
  @param string|Path|NULL $cwd
  @throws \InvalidArgumentException
  @return boolean
docstring_tokens: Tests whether the path is within the given directory .