Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
6 / 6
CRAP
100.00% covered (success)
100.00%
1 / 1
Half
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
6 / 6
10
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 set
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 exist
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 notExist
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 only
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 notOnly
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3/**
4 * @license MIT
5 * @author hazuki3417<hazuki3417@gmail.com>
6 * @copyright 2021 hazuki3417 all rights reserved.
7 */
8
9namespace Selen\Str\Verify\Width;
10
11class Half extends AbstractWidth
12{
13    private function __construct(string $val)
14    {
15        parent::__construct($val);
16    }
17
18    public static function set(string $val): Half
19    {
20        return new self($val);
21    }
22
23    public function exist(): bool
24    {
25        if ($this->str === '') {
26            return false;
27        }
28        return $this->getStrWidth() !== $this->calcStrAllFullWidth();
29    }
30
31    public function notExist(): bool
32    {
33        if ($this->str === '') {
34            return true;
35        }
36        return $this->getStrWidth() === $this->calcStrAllFullWidth();
37    }
38
39    public function only(): bool
40    {
41        if ($this->str === '') {
42            return false;
43        }
44        return $this->getStrWidth() === $this->calcStrAllHalfWidth();
45    }
46
47    public function notOnly(): bool
48    {
49        if ($this->str === '') {
50            return true;
51        }
52        return $this->getStrWidth() !== $this->calcStrAllHalfWidth();
53    }
54}