minify/src/d2b8599a-d5ce-49b1-b992-764...
Robot e23917c5e1
update 2024-04-07 13:20:18
2024-04-07 13:20:29 +02:00
..
README.md first commit 2023-04-15 16:58:37 +02:00
code.php first commit 2023-04-15 16:58:37 +02:00
code.power first commit 2023-04-15 16:58:37 +02:00
settings.json update 2024-04-07 13:20:18 2024-04-07 13:20:29 +02:00

README.md

██████╗  ██████╗ ██╗    ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║    ██║██╔════╝██╔══██╗
██████╔╝██║   ██║██║ █╗ ██║█████╗  ██████╔╝
██╔═══╝ ██║   ██║██║███╗██║██╔══╝  ██╔══██╗
██║     ╚██████╔╝╚███╔███╔╝███████╗██║  ██║
╚═╝      ╚═════╝  ╚══╝╚══╝ ╚══════╝╚═╝  ╚═╝

abstract class Minify (Details)

namespace: VDM\Minify\Abstraction

@startuml
abstract Minify  #Orange {
  # $data
  # $patterns
  + $extracted
  + __construct($data = null)
  + add(string|string[] $data = null) : static
  + addFile(string|string[] $data = null) : static
  + minify(string[optional] $path = null) : string
  + gzip(string[optional] $path = null, int[optional] $level = 9) : string
  + cache(CacheItemInterface $item) : CacheItemInterface
  + {abstract} execute(string[optional] $path = null) : string
  # load(string $data) : string
  # save(string $content, string $path)
  # registerPattern(string $pattern, string|callable $replacement = '')
  # replace(string $content) : string
  # executeReplacement(string|callable $replacement, array $match) : string
  # extractStrings(string[optional] $chars = '\'"', string[optional] $placeholderPrefix = '')
  # restoreExtractedData(string $content) : string
  # canImportFile(string $path) : bool
  # openFileForWriting(string $path) : resource
  # writeToFile(resource $handler, string $content, ...)
  # {static} str_replace_first($search, $replace, ...)
}

note right of Minify::__construct
  Init the minify class - optionally, code may be passed along already.

end note

note left of Minify::add
  Add a file or straight-up code to be minified.

  return: static
end note

note right of Minify::addFile
  Add a file to be minified.

  return: static
end note

note left of Minify::minify
  Minify the data & (optionally) saves it to a file.

  return: string
end note

note right of Minify::gzip
  Minify & gzip the data & (optionally) saves it to a file.

  return: string
end note

note left of Minify::cache
  Minify the data & write it to a CacheItemInterface object.

  return: CacheItemInterface
end note

note right of Minify::execute
  Minify the data.

  return: string
end note

note left of Minify::load
  Load data.

  return: string
end note

note right of Minify::save
  Save to file.

end note

note left of Minify::registerPattern
  Register a pattern to execute against the source content.
If $replacement is a string, it must be plain text. Placeholders like $1 or \2 don't work.
If you need that functionality, use a callback instead.

end note

note right of Minify::replace
  We can't "just" run some regular expressions against JavaScript: it's a
complex language. E.g. having an occurrence of // xyz would be a comment,
unless it's used within a string. Of you could have something that looks
like a 'string', but inside a comment.
The only way to accurately replace these pieces is to traverse the JS one
character at a time and try to find whatever starts first.

  return: string
end note

note left of Minify::executeReplacement
  If $replacement is a callback, execute it, passing in the match data.
If it's a string, just pass it through.

  return: string
end note

note right of Minify::extractStrings
  Strings are a pattern we need to match, in order to ignore potential
code-like content inside them, but we just want all of the string
content to remain untouched.
This method will replace all string content with simple STRING#
placeholder text, so we've rid all strings from characters that may be
misinterpreted. Original string content will be saved in $this->extracted
and after doing all other minifying, we can restore the original content
via restoreStrings().

end note

note left of Minify::restoreExtractedData
  This method will restore all extracted data (strings, regexes) that were
replaced with placeholder text in extract*(). The original content was
saved in $this->extracted.

  return: string
end note

note right of Minify::canImportFile
  Check if the path is a regular file and can be read.

  return: bool
end note

note left of Minify::openFileForWriting
  Attempts to open file specified by $path for writing.

  return: resource
end note

note right of Minify::writeToFile
  Attempts to write $content to the file specified by $handler. $path is used for printing exceptions.

  
  arguments:
    resource $handler
    string $content
    string $path = ''
end note

note left of Minify::str_replace_first
  
  arguments:
    $search
    $replace
    $subject
end note
 
@enduml

     ██╗ ██████╗██████╗
     ██║██╔════╝██╔══██╗
     ██║██║     ██████╔╝
██   ██║██║     ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
 ╚════╝  ╚═════╝╚═════╝

Build with Joomla Component Builder