Skip to content

Commit 530f6c6

Browse files
committed
Adds Pointer object.
1 parent b665258 commit 530f6c6

1 file changed

Lines changed: 83 additions & 0 deletions

File tree

src/Object/System/Pointer.php

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
3+
namespace DevCoding\Object\System;
4+
5+
/**
6+
* Object representing the pointer on a device.
7+
*
8+
* @author AMJones <am@jonesiscoding.com>
9+
* @license https://github.com/deviscoding/objection/blob/main/LICENSE
10+
* @package DevCoding\Object\System
11+
*/
12+
class Pointer
13+
{
14+
/** @var string The primary input mechanism includes an accurate pointing device. */
15+
const FINE = 'fine';
16+
/** @var string The primary input mechanism includes a pointing device of limited accuracy. */
17+
const COARSE = 'coarse';
18+
/** @var string The primary input mechanism cannot be identified. */
19+
const INCONCLUSIVE = 'inconclusive';
20+
/** @var string The primary input mechanism does not include a pointing device. */
21+
const NONE = 'none';
22+
23+
/** @var string The type of pointer: fine, coarse, none, or inconclusive */
24+
protected $type;
25+
/** @var bool If known; whether the device also has touch capabilities */
26+
protected $touch;
27+
/** @var bool If known; whether the device is using Windows 8's Metro Mode (full screen mode) */
28+
protected $metro;
29+
30+
/**
31+
* @param string $type One of the class constants
32+
* @param bool $touch If known; whether the device also has touch capabilities
33+
* @param bool $metro If known; whether the device is using Windows 8's Metro Mode (full screen mode)
34+
*/
35+
public function __construct($type, $touch = true, $metro = false)
36+
{
37+
$this->type = $type;
38+
$this->touch = $touch;
39+
$this->metro = $metro;
40+
}
41+
42+
/**
43+
* Returns the type of pointer as a string: fine, coarse, none, or inconclusive.
44+
*
45+
* @return string
46+
*/
47+
public function getType(): string
48+
{
49+
return $this->type;
50+
}
51+
52+
/**
53+
* @return bool
54+
*/
55+
public function isCoarse()
56+
{
57+
return 'coarse' === $this->getType();
58+
}
59+
60+
/**
61+
* @return bool
62+
*/
63+
public function isFine()
64+
{
65+
return 'fine' === $this->getType();
66+
}
67+
68+
/**
69+
* @return bool
70+
*/
71+
public function isTouch()
72+
{
73+
return $this->touch;
74+
}
75+
76+
/**
77+
* @return bool
78+
*/
79+
public function isMetro()
80+
{
81+
return $this->metro;
82+
}
83+
}

0 commit comments

Comments
 (0)