/**
  * Create a file access mode instance based on a PHP file access modes string.
  * This method won't verify the validity of the file access mode string.
  *
  * @param string $mode PHPs file access mode string.
  *
  * @return FileAccessMode|null The file access mode instance, or null on failure.
  */
 public static function createFromMode($mode)
 {
     // Return $mode if it's an FileAccessMode instance
     if ($mode instanceof FileAccessMode) {
         return $mode;
     }
     // Create and return a new file access mode instance
     return new FileAccessMode(StringUtils::contains($mode, '+'), !StringUtils::contains($mode, 'r') || StringUtils::contains($mode, '+'), !StringUtils::contains($mode, 'r'), StringUtils::contains($mode, 'x'), StringUtils::contains($mode, 'w'), StringUtils::contains($mode, 'a'), StringUtils::contains($mode, 't'), StringUtils::contains($mode, 'b'));
 }
示例#2
0
 /**
  * Check whether there is a relative keyword in the date and time string, this is to create dates relative to now for test instances, for example 'tomorrow' or 'next tuesday'.
  *
  * @param string $dateTime The date and time string to check.
  *
  * @return bool True if there is a relative keyword in the date and time string, false otherwise.
  */
 public static function hasRelativeKeywords($dateTime)
 {
     // Check whether the time string contains any relative keywords, skip the common time format
     if (preg_match('/[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}/', $dateTime) !== 1) {
         if (StringUtils::contains($dateTime, static::$RELATIVE_KEYWORDS, false)) {
             return true;
         }
     }
     // The time string doesn't contain any relative keywords, return the result
     return false;
 }