# optimole-wp/4.2.5/vendor/codeinwp/optimole-sdk/src/Resource/ImageProperty/DprProperty.php

Optimole – Optimize Images | Convert WebP &amp; AVIF | CDN &amp; Lazy Load | Image Optimization, version 4.2.5. 47 lines.

- Page: https://pluginprobe.com/plugins/optimole-wp/4.2.5/code/vendor/codeinwp/optimole-sdk/src/Resource/ImageProperty/DprProperty.php
- Raw: https://pluginprobe.com/plugins/optimole-wp/4.2.5/raw/vendor/codeinwp/optimole-sdk/src/Resource/ImageProperty/DprProperty.php
- Modified: 2025-04-14T10:28:30+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/optimole-wp/4.2.5/code/vendor/codeinwp/optimole-sdk/src/Resource/ImageProperty/DprProperty.php#L10-L20`.

```php
<?php

declare(strict_types=1);

/*
 * This file is part of Optimole PHP SDK.
 *
 * (c) Optimole Team <friends@optimole.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Optimole\Sdk\Resource\ImageProperty;

use Optimole\Sdk\Exception\InvalidArgumentException;
use Optimole\Sdk\Resource\PropertyInterface;

class DprProperty implements PropertyInterface
{
    /**
     * The dpr of the image.
     */
    private $dpr;

    /**
     * Constructor.
     */
    public function __construct($dpr = 1)
    {
        if (!is_int($dpr) || $dpr < 1) {
            throw new InvalidArgumentException('Image dpr must be an integer greater or equal than 1.');
        }
        $dpr = max(1, min(5, $dpr));

        $this->dpr = $dpr;
    }

    /**
     * {@inheritdoc}
     */
    public function __toString(): string
    {
        return sprintf('dpr:%s', $this->dpr);
    }
}

```
