### Crop   A last analyzed 2017-08-21 12:57 UTC

#### Coupling/Cohesion

 Components 1 Dependencies 2

#### Complexity

 Total Complexity 17

#### Size/Duplication

 Total Lines 75 Duplicated Lines 0 %

#### Test Coverage

 Coverage 82.98%

#### Importance

 Changes 0
Metric Value
wmc 17
lcom 1
cbo 2
dl 0
loc 75
ccs 39
cts 47
cp 0.8298
rs 10
c 0
b 0
f 0

#### 3 Methods

Rating   Name   Duplication   Size   Complexity
A run() 0 17 2
C getCoordinates() 0 25 12
A limitToImageBoundaries() 0 12 3
 1 `getCoordinates(\$image);` 20 21 2 ` if (\$coordinates) {` 22 2 ` \$coordinates = \$this->limitToImageBoundaries(\$image, \$coordinates);` 23 24 2 ` \$image->crop(` 25 2 ` \$coordinates[0],` 26 2 ` \$coordinates[1],` 27 2 ` \$coordinates[2],` 28 2 ` \$coordinates[3]` 29 2 ` );` 30 2 ` }` 31 32 2 ` return \$image;` 33 ` }` 34 35 ` /**` 36 ` * Resolve coordinates.` 37 ` * @param Image \$image The source image.` 38 ` * @return int[] The resolved coordinates.` 39 ` */` 40 4 ` public function getCoordinates(Image \$image)` 41 ` {` 42 4 ` \$coordinates = explode(',', \$this->crop);` 43 44 4 ` if (count(\$coordinates) !== 4 or` 45 4 ` (!is_numeric(\$coordinates[0])) or` 46 4 ` (!is_numeric(\$coordinates[1])) or` 47 4 ` (!is_numeric(\$coordinates[2])) or` 48 4 ` (!is_numeric(\$coordinates[3])) or` 49 4 ` (\$coordinates[0] <= 0) or` 50 4 ` (\$coordinates[1] <= 0) or` 51 4 ` (\$coordinates[2] < 0) or` 52 4 ` (\$coordinates[3] < 0) or` 53 4 ` (\$coordinates[2] >= \$image->width()) or` 54 4 ` (\$coordinates[3] >= \$image->height())) {` 55 2 ` return;` 56 ` }` 57 58 ` return [` 59 4 ` (int) \$coordinates[0],` 60 4 ` (int) \$coordinates[1],` 61 4 ` (int) \$coordinates[2],` 62 4 ` (int) \$coordinates[3],` 63 4 ` ];` 64 ` }` 65 66 ` /**` 67 ` * Limit coordinates to image boundaries.` 68 ` * @param Image \$image The source image.` 69 ` * @param int[] \$coordinates The coordinates.` 70 ` * @return int[] The limited coordinates.` 71 ` */` 72 4 ` public function limitToImageBoundaries(Image \$image, array \$coordinates)` 73 ` {` 74 4 ` if (\$coordinates[0] > (\$image->width() - \$coordinates[2])) {` 75 2 ` \$coordinates[0] = \$image->width() - \$coordinates[2];` 76 2 ` }` 77 78 4 ` if (\$coordinates[1] > (\$image->height() - \$coordinates[3])) {` 79 2 ` \$coordinates[1] = \$image->height() - \$coordinates[3];` 80 2 ` }` 81 82 4 ` return \$coordinates;` 83 ` }` 84 `}` 85