Sand Fox (Posts about bittorrent)https://sandfox.me/tags/bittorrent.xml2024-03-25T17:50:27ZAnton SmirnovNikolaMarch Packages on Packagisthttps://sandfox.me/php/arithmetics-clock-torrent.html2023-03-31T04:05:00+03:002023-03-31T04:05:00+03:00Anton Smirnov<p>I'm continuing to publish useless nih junk on the Packagist:</p>
<ul>
<li><p><a class="reference external" href="https://packagist.org/packages/arokettu/arithmetic-parser">arokettu/arithmetic-parser</a>:
A very configurable arithmetic parser and calculator.
You can define your own set of functions and operators.
You can even disable multiplication if you want to!</p></li>
<li><p><a class="reference external" href="https://packagist.org/packages/arokettu/clock">arokettu/clock</a>:
A set of PSR-20 clock implementations.
Everyone has these implemented so why not me? :D</p></li>
<li><p><a class="reference external" href="https://packagist.org/packages/arokettu/system-clock">arokettu/system-clock</a>:
All these PSR-20 clock packages usually contain a ton of clocks for testing purposes but
most of the production code needs only <code class="docutils literal">new <span class="pre">DateTimeImmutable('now')</span></code>
so I extracted SystemClock to a separate package that has only SystemClock.php and composer.json
for the smallest possible package (if you don't count uglifying it js-like)</p></li>
<li><p><a class="reference external" href="https://packagist.org/packages/arokettu/kilo-mega">arokettu/kilo-mega</a>:
This one was actually released on February but I've forgot to write about it.
It's a simple formatter for metric prefixes.</p>
<div class="code"><pre class="code php"><a id="rest_code_bdac7edff7c44a65b5892f661c0276be-1" name="rest_code_bdac7edff7c44a65b5892f661c0276be-1" href="https://sandfox.me/php/arithmetics-clock-torrent.html#rest_code_bdac7edff7c44a65b5892f661c0276be-1"></a><span class="cp"><?php</span>
<a id="rest_code_bdac7edff7c44a65b5892f661c0276be-2" name="rest_code_bdac7edff7c44a65b5892f661c0276be-2" href="https://sandfox.me/php/arithmetics-clock-torrent.html#rest_code_bdac7edff7c44a65b5892f661c0276be-2"></a><span class="k">echo</span> <span class="nx">format_metric</span><span class="p">(</span><span class="mi">1000</span><span class="p">,</span> <span class="nx">suffix</span><span class="o">:</span> <span class="s1">'W'</span><span class="p">);</span> <span class="c1">// 1.0 kW</span>
<a id="rest_code_bdac7edff7c44a65b5892f661c0276be-3" name="rest_code_bdac7edff7c44a65b5892f661c0276be-3" href="https://sandfox.me/php/arithmetics-clock-torrent.html#rest_code_bdac7edff7c44a65b5892f661c0276be-3"></a><span class="k">echo</span> <span class="nx">format_bytes</span><span class="p">(</span><span class="mi">1234</span><span class="p">);</span> <span class="c1">// 1.2 KiB</span>
</pre></div>
</li>
</ul>
<p>Also a new significant release:</p>
<ul class="simple">
<li><p><a class="reference external" href="https://packagist.org/packages/arokettu/torrent-file">arokettu/torrent-file</a>:
Torrent file class got file listing classes for v1 and v2 metadata in 5.0 release.</p></li>
</ul>