UseMuffin / Obfuscate

@@ -0,0 +1,74 @@
Loading
1 +
<?php
2 +
namespace Muffin\Obfuscate\Model\Behavior\Strategy;
3 +
4 +
use Cake\ORM\Table;
5 +
6 +
/**
7 +
 * Class UuidStrategy
8 +
 *
9 +
 */
10 +
class UuidStrategy implements StrategyInterface
11 +
{
12 +
13 +
    /**
14 +
     * UUID field to use.
15 +
     *
16 +
     * @var string
17 +
     */
18 +
    protected $_field;
19 +
20 +
    /**
21 +
     * Table using this strategy.
22 +
     *
23 +
     * @var Table
24 +
     */
25 +
    protected $_table;
26 +
27 +
    /**
28 +
     * Constructor.
29 +
     *
30 +
     * @param Table $table Instance of the table using the strategy.
31 +
     * @param string $field Name of the UUID field on the table.
32 +
     */
33 +
    public function __construct($table, $field = 'uuid')
34 +
    {
35 +
        $this->_table = $table;
36 +
        $this->_field = $field;
37 +
    }
38 +
39 +
    /**
40 +
     * {@inheritdoc}
41 +
     *
42 +
     * @param string $str String to obfuscate.
43 +
     * @return string
44 +
     */
45 +
    public function obfuscate($str)
46 +
    {
47 +
        $record = $this->_table
48 +
            ->find()
49 +
            ->where([$this->_table->getPrimaryKey() => $str])
50 +
            ->select([$this->_field])
51 +
            ->firstOrFail();
52 +
53 +
        return $record->{$this->_field};
54 +
    }
55 +
56 +
    /**
57 +
     * {@inheritdoc}
58 +
     *
59 +
     * @param string $str String to elucidate.
60 +
     * @return string
61 +
     */
62 +
    public function elucidate($str)
63 +
    {
64 +
        $pk = $this->_table->getPrimaryKey();
65 +
66 +
        $record = $this->_table
67 +
            ->find()
68 +
            ->where([$this->_field => $str])
69 +
            ->select([$pk])
70 +
            ->firstOrFail();
71 +
72 +
        return $record->$pk;
73 +
    }
74 +
}
Files Complexity Coverage
src/Model/Behavior 37 97.78%
Project Totals (5 files) 37 97.78%
74.4
7.2=.2
TRAVIS_OS_NAME=linux
74.5
7.2=.2
TRAVIS_OS_NAME=linux
78.5
7.2=.2
TRAVIS_OS_NAME=linux
74.6
7.2=.2
TRAVIS_OS_NAME=linux
78.6
7.2=.2
TRAVIS_OS_NAME=linux
78.4
7.2=.2
TRAVIS_OS_NAME=linux
81.5
7.2=.2
TRAVIS_OS_NAME=linux
81.4
7.2=.2
TRAVIS_OS_NAME=linux
81.6
7.2=.2
TRAVIS_OS_NAME=linux

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading