Test whether the given image exists.

@param string $uuidImage  The uuid of the image.
@param string $strDefault Path to the fallback image.

@return string If the image exists, the image is returned, the default otherwise.
182954
protected function ensureImage($uuidImage, $strDefault)
    {
        $imagePath = ToolboxFile::convertValueToPath($uuidImage);
        if (\strlen($imagePath) && \file_exists(TL_ROOT . '/' . $imagePath)) {
            return $imagePath;
        }

        return $strDefault;
    }
278563
public function getHole($uuid)
    {
        $found = null;
        foreach ($this->holes as $hole) {
            if ($hole->getUuid() === $uuid) {
                $found = $hole;
                break;
            }
        }

        return $found;
    }
886633
function uc( $str, $first = false ) {
		if ( function_exists( 'mb_strtoupper' ) ) {
			if ( $first ) {
				if ( $this->isMultibyte( $str ) ) {
					return mb_strtoupper( mb_substr( $str, 0, 1 ) ) . mb_substr( $str, 1 );
				} else {
					return ucfirst( $str );
				}
			} else {
				return $this->isMultibyte( $str ) ? mb_strtoupper( $str ) : strtoupper( $str );
			}
		} else {
			if ( $this->isMultibyte( $str ) ) {
				$x = $first ? '^' : '';
				return preg_replace_callback(
					"/$x([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)/",
					array( $this, 'ucCallback' ),
					$str
				);
			} else {
				return $first ? ucfirst( $str ) : strtoupper( $str );
			}
		}
	}
19577
public function getItem($uuid)
    {
        $found = null;
        foreach ($this->items as $item) {
            if ($item->getUuid() === $uuid) {
                $found = $item;
                break;
            }
        }

        return $found;
    }
275681
public function getQuestion($uuid)
    {
        $found = null;
        foreach ($this->stepQuestions as $stepQuestion) {
            if ($stepQuestion->getQuestion()->getUuid() === $uuid) {
                $found = $stepQuestion->getQuestion();
                break;
            }
        }

        return $found;
    }
973248
public static UUID attemptUUIDParse(BufferedString str) {
    Long lo = attemptUUIDParseLow(str);
    Long hi = attemptUUIDParseHigh(str);
    return (str.getOffset() == -1) ? null : buildUUID(lo, hi);
  }
1335086
public static boolean isValidUUID(String uuid) {
        return !StringUtils.isEmpty(uuid) && UUID_PATTERN.matcher(uuid).matches();
    }
507004
public static function isValid(string $uuid): bool
    {
        $uuid = strtolower(str_replace(['urn:', 'uuid:', '{', '}'], '', $uuid));

        if (!preg_match(static::UUID, $uuid)) {
            return false;
        }

        return true;
    }
884335
public function getDefaultImageUrl($filter)
    {
        $config = $this->filterConfig->get($filter);

        $defaultImage = null;
        if (false === empty($config['default_image'])) {
            $defaultImage = $config['default_image'];
        } elseif (!empty($this->globalDefaultImage)) {
            $defaultImage = $this->globalDefaultImage;
        }

        return $defaultImage;
    }
1200282
private function generateUUID()
    {
        return sprintf(
            '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
            mt_rand(0, 0xffff),
            mt_rand(0, 0xffff),
            mt_rand(0, 0xffff),
            mt_rand(0, 0x0fff) | 0x4000,
            mt_rand(0, 0x3fff) | 0x8000,
            mt_rand(0, 0xffff),
            mt_rand(0, 0xffff),
            mt_rand(0, 0xffff)
        );
    }
718802
def get_unresolved_support_uuids(stmts):
    """"""
    return {s.uuid for stmt in stmts for s in stmt.supports + stmt.supported_by
            if isinstance(s, Unresolved)}
65941
protected function getUuidFromUrl(Url $url)
    {
        $segments = $url->getPathSegments();

        if (count($segments) < 1) {
            throw new Exception('Invalid UUID');
        }

        if (count($segments) < 2) {
            return $segments[0];
        }

        return $segments[count($segments) - 2];
    }
524902
public static function getUniqueId($uriResource)
    {
        $returnValue = '';

        if (stripos($uriResource, "#") > 0) {
            $returnValue = substr($uriResource, stripos($uriResource, "#") + 1);
        }

        return $returnValue;
    }
680425
static public function uuid($value, $message = null, $propertyPath = null)
        {
            $value = str_replace(
                array(
                    'urn:',
                    'uuid:',
                    '{', '}'
                ),
                '',
                $value
            );

            if ($value === '00000000-0000-0000-0000-000000000000') {
                return;
            }

            if (!preg_match('/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[1-5][0-9A-Fa-f]{3}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/', $value)) {
                $message = $message ?: sprintf(
                    'Value "%s" is not a valid UUID.',
                    static::stringify($value)
                );

                throw static::createException($value, $message, static::INVALID_UUID, $propertyPath);
            }
        }
789228
private boolean isUUID(String uuid) {
        try {
            UUID.fromString(uuid);
            return true;
        } catch (Exception ex) {
            return false;
        }
    }
1178872
protected function findModelByUUID($uuid)
    {
        if (($model = Article::findOne(['uuid' => $uuid])) != null) {
            return $model;
        }
        throw new NotFoundHttpException(Yii::t('yii', 'The requested page does not exist'));
    }
692387
public static function saveById($userId, $originalImage): bool
    {
        $user = User::findOne(['id' => $userId]);
        if ($user) {
            return self::save($user, $originalImage);
        }
        return false;
    }