You probably know shield badges (from shields.io).
They are dynamically created svg images of two types:
1. Value Badges
<img src="https://img.shields.io/badge/value-5555ff">
2. Key-Value Badges
<img src="https://img.shields.io/badge/key-value-5555ff">
They are great, however, there are two problems with them:
- They are an extra dependency (no badges if shields.io is down)
- For every badge we have an additional http request (long loading time)
Let's say I am already using bootstrap in my project (self-hosted to minimize dependencies). How can I create those two types of badges dynamically with bootstrap?
(I also use PHP, so a badge($name, $value, $color) function would be amazing)

The very basic OOP approach would look like:
So you can use it in your code by:
Note 0: Of course it's rather POC than an exact solution, so you need to polish it by yourself ;)
Note 1: As newest Bootstrap doesn't use any icon set by default, icons are dummy so you need to fix it to use with your chosen icon set or just by custom CSS styling.
Note 2: We do not use any setter for value as we want to make usage of array, therefore use
addValue()to get pipe-separated values.