<?php
<?php
class Direction {
public $departments = array();
public function dismissEmployees($type) {
$filteredEmployees = array();
foreach ($this->departments as $departmentkey => $department) {
$filteredEmployees = array_filter($department->employees, function($f) use ($type) {return ($f->name == $type) and
($f->leader != true);}); $totalEmployeesType = count($filteredEmployees);
if($totalEmployeesType == 0) {
continue;
}
$percent = ceil(($totalEmployeesType / 100) * 40);
usort($filteredEmployees, function($a, $b) { if ($a->rang == $b->rang) {
return 0;
}
return ($a->rang < $b->rang) ? -1 : 1;
});
$focusEmployees = array_slice($filteredEmployees, 0, $percent);
$department->employees = array_udiff($department->employees, $focusEmployees, function($a, $b) {return ($a != $b);}); }
return true;
}
}
PD9waHAKPD9waHAKY2xhc3MgRGlyZWN0aW9uIHsKCXB1YmxpYyAkZGVwYXJ0bWVudHMgPSBhcnJheSgpOwoKCXB1YmxpYyBmdW5jdGlvbiBkaXNtaXNzRW1wbG95ZWVzKCR0eXBlKSB7CgkJJGZpbHRlcmVkRW1wbG95ZWVzID0gYXJyYXkoKTsKCgkJZm9yZWFjaCAoJHRoaXMtPmRlcGFydG1lbnRzIGFzICRkZXBhcnRtZW50a2V5ID0+ICRkZXBhcnRtZW50KSB7CgkJCSRmaWx0ZXJlZEVtcGxveWVlcyA9IGFycmF5X2ZpbHRlcigkZGVwYXJ0bWVudC0+ZW1wbG95ZWVzLCBmdW5jdGlvbigkZikgdXNlICgkdHlwZSkge3JldHVybiAoJGYtPm5hbWUgPT0gJHR5cGUpIGFuZCAoJGYtPmxlYWRlciAhPSB0cnVlKTt9KTsKCQkJJHRvdGFsRW1wbG95ZWVzVHlwZSA9IGNvdW50KCRmaWx0ZXJlZEVtcGxveWVlcyk7IAoKCQkJaWYoJHRvdGFsRW1wbG95ZWVzVHlwZSA9PSAwKSB7CgkJCQljb250aW51ZTsKCQkJfQoJCQkKCQkJJHBlcmNlbnQgPSBjZWlsKCgkdG90YWxFbXBsb3llZXNUeXBlIC8gMTAwKSAqIDQwKTsKCgkJCXVzb3J0KCRmaWx0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