mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 20:10:08 +02:00
30 lines
722 B
Swift
30 lines
722 B
Swift
//
|
|
// PhpVersionExtractor.swift
|
|
// PHP Monitor
|
|
//
|
|
// Created by Nico Verbruggen on 11/06/2019.
|
|
// Copyright © 2019 Nico Verbruggen. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
class PhpVersion {
|
|
|
|
var short : String = "???"
|
|
var long : String = "???"
|
|
|
|
init() {
|
|
let version = Shell.user
|
|
// Get the version directly from PHP
|
|
.pipe("php -r 'print phpversion();'")
|
|
|
|
// That's the long version
|
|
self.long = version
|
|
|
|
// Next up, let's strip away the minor version number
|
|
let segments = long.components(separatedBy: ".")
|
|
// Get the first two elements
|
|
self.short = segments[0...1].joined(separator: ".")
|
|
}
|
|
}
|