Best Atoum code snippet using path.exists
functions-helpers.php
Source:functions-helpers.php
...9 * @license https://opensource.org/licenses/MIT10 */11use Blush\{App, Config, Url};12use Blush\Tools\{Collection, Str};13if ( ! function_exists( 'app' ) ) {14 /**15 * Returns an instance of the application or a binding.16 *17 * @since 1.0.018 */19 function app( string $abstract = '', array $params = [] ): mixed20 {21 return App::resolve( $abstract ?: 'app', $params );22 }23}24if ( ! function_exists( 'env' ) ) {25 /**26 * Returns an environment variable if it is set or `null`.27 *28 * @since 1.0.029 */30 function env( string $var, ?string $default = null ): ?string31 {32 return $_ENV[ $var ] ?? $default;33 }34}35if ( ! function_exists( 'environment' ) ) {36 /**37 * Returns the application environment.38 *39 * @since 1.0.040 */41 function environment(): string42 {43 return env( 'APP_ENV', 'development' );44 }45}46if ( ! function_exists( 'config' ) ) {47 /**48 * Returns a value from the configuration instance using either dot49 * (e.g., `app.example`) or slash (e.g., `app/example`) notation.50 *51 * @since 1.0.052 * @param string $deprecated Setting key. Use dot notation instead.53 */54 function config( string $name, string $deprecated = '' ): mixed55 {56 if ( $deprecated && ! Str::contains( $name, '.' ) ) {57 $name = "{$name}.{$deprecated}";58 }59 return Config::get( $name );60 }61}62if ( ! function_exists( 'route' ) ) {63 /**64 * Returns the named route URL.65 *66 * @since 1.0.067 */68 function route( string $name, array $params = [] ): string69 {70 return Url::route( $name, $params );71 }72}73if ( ! function_exists( 'path' ) ) {74 /**75 * Returns app path with optional appended path/file.76 *77 * @since 1.0.078 */79 function path( string $append = '' ): string80 {81 return app()->path( append: $append );82 }83}84if ( ! function_exists( 'app_path' ) ) {85 /**86 * Returns app path with optional appended path/file.87 *88 * @since 1.0.089 */90 function app_path( string $append = '' ): string91 {92 return app()->appPath( $append );93 }94}95if ( ! function_exists( 'config_path' ) ) {96 /**97 * Returns public path with optional appended path/file.98 *99 * @since 1.0.0100 */101 function config_path( string $append = '' ): string102 {103 return app()->configPath( $append );104 }105}106if ( ! function_exists( 'public_path' ) ) {107 /**108 * Returns public path with optional appended path/file.109 *110 * @since 1.0.0111 */112 function public_path( string $append = '' ): string113 {114 return app()->publicPath( $append );115 }116}117if ( ! function_exists( 'view_path' ) ) {118 /**119 * Returns view path with optional appended path/file.120 *121 * @since 1.0.0122 */123 function view_path( string $append = '' ): string124 {125 return app()->viewPath( $append );126 }127}128if ( ! function_exists( 'resource_path' ) ) {129 /**130 * Returns resource path with optional appended path/file.131 *132 * @since 1.0.0133 */134 function resource_path( string $append = '' ): string135 {136 return app()->resourcePath( $append );137 }138}139if ( ! function_exists( 'storage_path' ) ) {140 /**141 * Returns storage path with optional appended path/file.142 *143 * @since 1.0.0144 */145 function storage_path( string $append = '' ): string146 {147 return app()->storagePath( $append );148 }149}150if ( ! function_exists( 'cache_path' ) ) {151 /**152 * Returns cache path with optional appended path/file.153 *154 * @since 1.0.0155 */156 function cache_path( string $append = '' ): string157 {158 return app()->cachePath( $append );159 }160}161if ( ! function_exists( 'user_path' ) ) {162 /**163 * Returns user path with optional appended path/file.164 *165 * @since 1.0.0166 */167 function user_path( string $append = '' ): string168 {169 return app()->userPath( $append );170 }171}172if ( ! function_exists( 'content_path' ) ) {173 /**174 * Returns content path with optional appended path/file.175 *176 * @since 1.0.0177 */178 function content_path( string $append = '' ): string179 {180 return app()->contentPath( $append );181 }182}183if ( ! function_exists( 'media_path' ) ) {184 /**185 * Returns media path with optional appended path/file.186 *187 * @since 1.0.0188 */189 function media_path( string $append = '' ): string190 {191 return app()->mediaPath( $append );192 }193}194if ( ! function_exists( 'vendor_path' ) ) {195 /**196 * Returns vendor path with optional appended path/file.197 *198 * @since 1.0.0199 */200 function vendor_path( string $append = '' ): string201 {202 return app()->vendorPath( $append );203 }204}205if ( ! function_exists( 'url' ) ) {206 /**207 * Returns app URL with optional appended path. If no appended path,208 * returns the `Url` object, which can be used as a string to get the209 * app URL. Or, it can be used as a static class to access its methods.210 *211 * @since 1.0.0212 */213 function url( string $append = '' ): Url|string214 {215 return $append ? Url::to( $append ) : Url::make();216 }217}218if ( ! function_exists( 'app_url' ) ) {219 /**220 * Returns config URL with optional appended path/file.221 *222 * @since 1.0.0223 */224 function app_url( string $append = '' ): string225 {226 return app()->appUrl( $append );227 }228}229if ( ! function_exists( 'config_url' ) ) {230 /**231 * Returns config URL with optional appended path/file.232 *233 * @since 1.0.0234 */235 function config_url( string $append = '' ): string236 {237 return app()->configUrl( $append );238 }239}240if ( ! function_exists( 'public_url' ) ) {241 /**242 * Returns public URL with optional appended path/file.243 *244 * @since 1.0.0245 */246 function public_url( string $append = '' ): string247 {248 return app()->publicUrl( $append );249 }250}251if ( ! function_exists( 'view_url' ) ) {252 /**253 * Returns view URL with optional appended path/file.254 *255 * @since 1.0.0256 */257 function view_url( string $append = '' ): string258 {259 return app()->viewUrl( $append );260 }261}262if ( ! function_exists( 'resource_url' ) ) {263 /**264 * Returns resource URL with optional appended path/file.265 *266 * @since 1.0.0267 */268 function resource_url( string $append = '' ): string269 {270 return app()->resourceUrl( $append );271 }272}273if ( ! function_exists( 'storage_url' ) ) {274 /**275 * Returns storage URL with optional appended path/file.276 *277 * @since 1.0.0278 */279 function storage_url( string $append = '' ): string280 {281 return app()->storageUrl( $append );282 }283}284if ( ! function_exists( 'cache_url' ) ) {285 /**286 * Returns cache URL with optional appended path/file.287 *288 * @since 1.0.0289 */290 function cache_url( string $append = '' ): string291 {292 return app()->cacheUrl( $append );293 }294}295if ( ! function_exists( 'user_url' ) ) {296 /**297 * Returns public URL with optional appended path/file.298 *299 * @since 1.0.0300 */301 function user_url( string $append = '' ): string302 {303 return app()->userUrl( $append );304 }305}306if ( ! function_exists( 'content_url' ) ) {307 /**308 * Returns content URL with optional appended path/file.309 *310 * @since 1.0.0311 */312 function content_url( string $append = '' ): string313 {314 return app()->contentUrl( $append );315 }316}317if ( ! function_exists( 'media_url' ) ) {318 /**319 * Returns media URL with optional appended path/file.320 *321 * @since 1.0.0322 */323 function media_url( string $append = '' ): string324 {325 return app()->mediaUrl( $append );326 }327}328if ( ! function_exists( 'vendor_url' ) ) {329 /**330 * Returns vendor URL with optional appended path/file.331 *332 * @since 1.0.0333 */334 function vendor_url( string $append = '' ): string335 {336 return app()->vendorUrl( $append );337 }338}339if ( ! function_exists( 'asset' ) ) {340 /**341 * Returns an asset URI with an ID query var attached to it based on the342 * file's last modified time. Used for cache busting. The `$path` param343 * must be a filename relative to the public path.344 *345 * @since 1.0.0346 */347 function asset( string $path ): string348 {349 $asset_url = public_url( $path );350 $modified = filemtime( public_path( $path ) );351 return false !== $modified ? "{$asset_url}?id={$modified}" : $asset_url;352 }353}354if ( ! function_exists( 'e' ) ) {355 /**356 * Convenient wrapper around `htmlspecialchars()` for escaping strings357 * before outputting HTML.358 *359 * @since 1.0.0360 */361 function e( string $value, bool $double_encode = true ): string362 {363 return htmlspecialchars( $value, ENT_QUOTES, 'UTF-8', $double_encode );364 }365}366if ( ! function_exists( 'escape_tag' ) ) {367 /**368 * Escapes an HTML tag name for use in HTML. Note that this does not369 * validate the tag, only makes it safe for output.370 *371 * @since 1.0.0372 */373 function escape_tag( string $tag ): string374 {375 return strtolower( preg_replace( '/[^a-zA-Z0-9_:]/', '', $tag ) );376 }377}378if ( ! function_exists( 'sanitize_slug' ) ) {379 /**380 * Sanitizes a string meant to be used as a slug.381 *382 * @since 1.0.0383 */384 function sanitize_slug( string $str, string $sep = '-' ): string385 {386 return Str::slug( $str, $sep );387 }388}389if ( ! function_exists( 'runt' ) ) {390 /**391 * Ensures that the final two words of string with three or more words392 * does not result in a runt (final word hangs on line by itself).393 *394 * @since 1.0.0395 */396 function runt( string $str ): string397 {398 return Str::runt( $str );399 }400}...
RealPath.php
Source:RealPath.php
...32{33 /**34 * @var boolean $_pathExists35 */36 protected $_exists = true;37 /**38 * Class constructor39 *40 * @param boolean|Zend_Config $options Options to set41 */42 public function __construct($options = true)43 {44 $this->setExists($options);45 }46 /**47 * Returns true if the filtered path must exist48 *49 * @return boolean50 */51 public function getExists()52 {53 return $this->_exists;54 }55 /**56 * Sets if the path has to exist57 * TRUE when the path must exist58 * FALSE when not existing paths can be given59 *60 * @param boolean|Zend_Config $exists Path must exist61 * @return Zend_Filter_RealPath62 */63 public function setExists($exists)64 {65 if ($exists instanceof Zend_Config) {66 $exists = $exists->toArray();67 }68 if (is_array($exists)) {69 if (isset($exists['exists'])) {70 $exists = (boolean) $exists['exists'];71 }72 }73 $this->_exists = (boolean) $exists;74 return $this;75 }76 /**77 * Defined by Zend_Filter_Interface78 *79 * Returns realpath($value)80 *81 * @param string $value82 * @return string83 */84 public function filter($value)85 {86 $path = (string) $value;87 if ($this->_exists) {88 return realpath($path);89 }90 $realpath = @realpath($path);91 if ($realpath) {92 return $realpath;93 }94 $drive = '';95 if (substr(PHP_OS, 0, 3) == 'WIN') {96 $path = preg_replace('/[\\\\\/]/', DIRECTORY_SEPARATOR, $path);97 if (preg_match('/([a-zA-Z]\:)(.*)/', $path, $matches)) {98 list($fullMatch, $drive, $path) = $matches;99 } else {100 $cwd = getcwd();101 $drive = substr($cwd, 0, 2);...
exists
Using AI Code Generation
1$path = new Path('1.php');2var_dump($path->exists());3var_dump($path->isReadable());4var_dump($path->isWritable());5var_dump($path->isExecutable());6var_dump($path->isFile());7var_dump($path->isDir());8var_dump($path->isLink());9var_dump($path->isHidden());10var_dump($path->getRealPath());11var_dump($path->getRelativePath());12var_dump($path->getRelativePathname());13var_dump($path->getFilename());14var_dump($path->getBasename());15var_dump($path->getExtension());16var_dump($path->getPerms());17var_dump($path->getInode());18var_dump($path->getSize());19var_dump($path->getOwner());20var_dump($path->getGroup());21var_dump($path->getATime());22var_dump($path->getMTime());23var_dump($path->getCTime());24var_dump($path->getType());25var_dump($path->getFileInfo());26var_dump($path->getPathInfo());
exists
Using AI Code Generation
1$path = new Path('1.php');2var_dump($path->exists());3bool(true)4$path = new Path('2.php');5var_dump($path->exists());6bool(false)7$path = new Path('3.php');8var_dump($path->exists());9bool(false)10$path = new Path('4.php');11var_dump($path->exists());12bool(false)13$path = new Path('5.php');14var_dump($path->exists());15bool(false)16$path = new Path('6.php');17var_dump($path->exists());18bool(false)19$path = new Path('7.php');20var_dump($path->exists());21bool(false)22$path = new Path('8.php');23var_dump($path->exists());24bool(false)25$path = new Path('9.php');26var_dump($path->exists());27bool(false)28$path = new Path('10.php');29var_dump($path->exists());30bool(false)31$path = new Path('11.php');32var_dump($path->exists());33bool(false)34$path = new Path('12.php');35var_dump($path->exists());36bool(false)
exists
Using AI Code Generation
1$myPath = new Path("1.php");2if($myPath->exists()) {3 echo "File exists";4} else {5 echo "File does not exist";6}7$myPath = new Path("1.php");8if($myPath->isdir()) {9 echo "File is a directory";10} else {11 echo "File is not a directory";12}13$myPath = new Path("1.php");14if($myPath->isfile()) {15 echo "File is a file";16} else {17 echo "File is not a file";18}19$myPath = new Path("1.php");20if($myPath->isabsolute()) {21 echo "File is an absolute path";22} else {23 echo "File is not an absolute path";24}25$myPath = new Path("1.php");26if($myPath->isrelative()) {27 echo "File is a relative path";28} else {29 echo "File is not a relative path";30}31$myPath = new Path("1.php");32echo $myPath->getfilename();33$myPath = new Path("1.php");34echo $myPath->getextension();35$myPath = new Path("1.php");36echo $myPath->getbasename();37$myPath = new Path("1.php");38echo $myPath->getdirname();39$myPath = new Path("1.php");40print_r($myPath->getpathinfo());41$myPath = new Path("1.php");42echo $myPath->getrealpath();43$myPath = new Path("1.php");44echo $myPath->getrelativepath();45$myPath = new Path("1.php");46echo $myPath->getparentpath();
exists
Using AI Code Generation
1$pth = new Path("1.php");2if($pth->exists())3{4echo "File Exists";5}6{7echo "File Does not Exists";8}9$pth = new Path("1.php");10if($pth->isdir())11{12echo "File is a Directory";13}14{15echo "File is not a Directory";16}17$pth = new Path("1.php");18if($pth->isfile())19{20echo "File is a File";21}22{23echo "File is not a File";24}25$pth = new Path("1.php");26if($pth->islink())27{28echo "File is a link";29}30{31echo "File is not a link";32}33$pth = new Path("1.php");34if($pth->isreadable())35{36echo "File is Readable";37}38{39echo "File is not Readable";40}41$pth = new Path("1.php");42if($pth->iswritable())43{44echo "File is Writable";45}46{47echo "File is not Writable";48}49$pth = new Path("1.php");50echo $pth->getsize();51$pth = new Path("1.php");52echo $pth->getatime();53$pth = new Path("1.php");54echo $pth->getmtime();55$pth = new Path("1.php");56echo $pth->getctime();57$pth = new Path("1.php");58echo $pth->getowner();
exists
Using AI Code Generation
1$path = new Path('1.php');2var_dump($path->exists());3bool(true)4$path = new Path('1.txt');5var_dump($path->exists());6bool(false)7$path = new Path('1.php');8var_dump($path->isDir());9bool(false)10$path = new Path('1');11var_dump($path->isDir());12bool(true)13$path = new Path('1.php');14var_dump($path->isFile());15bool(true)16$path = new Path('1');17var_dump($path->isFile());18bool(false)19$path = new Path('1.php');20var_dump($path->isLink());21bool(false)22$path = new Path('1');23var_dump($path->isLink());24bool(false)25$path = new Path('1.php');26var_dump($path->isReadable());27bool(true)28$path = new Path('1');29var_dump($path->isReadable());30bool(true)31$path = new Path('1.php');32var_dump($path->isWritable());33bool(true)34$path = new Path('1');35var_dump($path->isWritable());36bool(true)37$path = new Path('
exists
Using AI Code Generation
1$path = new Path('1.php');2if($path->exists()){3 print $path;4}else{5 print 'Path does not exist';6}7$path = new Path('1.php');8if($path->isFile()){9 print $path;10}else{11 print 'Path is not a file';12}13$path = new Path('1.php');14if($path->isDirectory()){15 print $path;16}else{17 print 'Path is not a directory';18}19$path = new Path('1.php');20if($path->isReadable()){21 print $path;22}else{23 print 'Path is not readable';24}25$path = new Path('1.php');26if($path->isWritable()){27 print $path;28}else{29 print 'Path is not writable';30}31$path = new Path('1.php');32if($path->isExecutable()){33 print $path;34}else{35 print 'Path is not executable';36}37$path = new Path('1.php');38if($path->isHidden()){39 print $path;40}else{41 print 'Path is not hidden';42}
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with exists on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!