inteve/utils

Utility classes for web development

Maintainers

Details

github.com/inteve/utils

Source

Issues

Fund package maintenance!
Other

v0.3.4 2023-06-27 06:46 UTC

This package is auto-updated.

Last update: 2024-10-27 10:00:32 UTC


README

Build Status Downloads this Month Latest Stable Version License

Utility classes for web development

Donate

Installation

Download a latest package or use Composer:

composer require inteve/utils

Inteve\Utils requires PHP 5.6.0 or later.

Usage

DateTimeFactory

$dateTimeFactory = new Inteve\Utils\DateTimeFactory;
$now = $dateTimeFactory->create();

Imagick

use Inteve\Utils\ImagickHelper;
$imagick = ImagickHelper::openImage('file.jpg');
ImagickHelper::resize($imagick, $width, $height, $flags); // same parameters as for Image::resize()
ImagickHelper::saveImage($imagick, 'thumb.jpg');

// and much more!

PaginatorHelper

$paginator = new Nette\Utils\Paginator;
$steps = Inteve\Utils\PaginatorHelper::calculateSteps($paginator);

XmlDocument

$xml = new Inteve\Utils\XmlDocument([
	'standalone' => 'yes',
]);
$root = $xml->create('urlset');

$item = $root->create('url');
$item->create('loc')->setText('http://example.com/');

echo $xml->toString();

Prints:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<urlset>
	<url>
		<loc>http://example.com/</loc>
	</url>
</urlset>

XmlQuery

Wrapper of SimpleXml.

$query = Inteve\Utils\XmlQuery::fromString('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<urlset>
	<url>
		<loc>http://example.com/</loc>
	</url>
	<url>
		<loc>http://example.com/path</loc>
	</url>
</urlset>');

$urls = [];

foreach ($query->children('url') as $url) {
	$urls[] = $url->child('loc')->text();
}

var_dump($urls);

Prints:

http://example.com/
http://example.com/path

License: New BSD License
Author: Jan Pecha, https://www.janpecha.cz/