1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-09 04:42:59 +02:00
Files
app/phpmon/Domain/SwiftUI/Modules/PHP Doctor/Data/Warning.swift
Nico Verbruggen 943b5aa6af ♻️ Code reorganization
It was necessary to do some summer cleaning. Here's what's changed:

* First, I'm taking a new modular approach to Swift-based components
  that are part of PHP Monitor.

* I've fixed the naming of various parts of the app. I plan on doing
  an even deeper check in the future. The following are affected:
  - "PHP Formulae Status" is now known as "PHP Version Manager".
  - "Warnings List" is now known as "PHP Doctor".
  - The associated window controllers have also been updated.

(I've also added a new module: "PHP Config Editor". We'll see what that
brings in the future... but the main purpose will be to edit key PHP
configuration values without needing to go to the .ini files.)
2023-07-18 19:52:15 +02:00

53 lines
1.3 KiB
Swift

//
// Warning.swift
// PHP Monitor
//
// Created by Nico Verbruggen on 09/08/2022.
// Copyright © 2023 Nico Verbruggen. All rights reserved.
//
import Foundation
struct Warning: Identifiable, Hashable {
var id = UUID()
let command: () async -> Bool
let name: String
let title: String
let paragraphs: () -> [String]
let url: String?
/**
- Parameters:
- command: The command that, if it returns true, means that a warning applies
- name: The internal name or description for this warning
- title: The title displayed for the user
- paragraphs: The main body of text displayed for the user
- url: The URL that one can navigate to for more information (if applicable)
*/
init(
command: @escaping () async -> Bool,
name: String,
title: String,
paragraphs: @escaping () -> [String],
url: String?
) {
self.command = command
self.name = name
self.title = title
self.paragraphs = paragraphs
self.url = url
}
public func applies() async -> Bool {
return await self.command()
}
public static func == (lhs: Warning, rhs: Warning) -> Bool {
return lhs.hashValue == rhs.hashValue
}
public func hash(into hasher: inout Hasher) {
hasher.combine(self.id)
}
}