This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class WidgetList { | |
public int numberOfWidgets () {...} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function validateEmail(email) { | |
// validate and return true or false | |
} | |
function isEmailValid(email) { | |
// validate and return true or false | |
} | |
function emailIsValid(email) { | |
// validate and return true or false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (expresion) { | |
return true; | |
} else { | |
return false; | |
} | |
// which can be refactored to | |
return expresion; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class User { | |
private $name; | |
private $age; | |
public function setName(string $name) { | |
$this->name = $name; | |
} | |
public function setAge($age):void |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export async function addVehicle(userId, vehicle) { | |
return api.addVehicle(userId, vehicle, axios).then(data => { | |
if (!data.errors) { | |
store.dispatch({ | |
type: types.ADD_VEHICLE, | |
vehicle: data.data.addVehicle | |
}); | |
return data; | |
} | |
return Promise.reject(data.errors); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export async function addVehicle(userId, vehicle) { | |
const data = await api.addVehicle(userId, vehicle, axios); | |
return dispatch({type: types.ADD_VEHICLE, data: {vehicle: data.data.addVehicle}}); | |
} | |
export async function updateVehicle(vehicle, index) { | |
const data = api.updateVehicle(vehicle, axios); | |
return dispatch({type:types.UPDATE_VEHICLE, data: {vehicle: data.data.updateVehicle, index}}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sum (num1, num2) { | |
return num1 + num2 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('Calculator', () => { | |
it('should get the sum of two numbers', () => { | |
const sum = sum(5, 5); | |
expect(sum).toEqual(10); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function describe(testcase, callback) { | |
console.log(testcase); | |
callback(); | |
} | |
function it(description, callback) { | |
callback(); | |
} | |
function expect(actualVal) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const assert = require("assert"); | |
// .. code | |
function expect(actual) { | |
return { | |
toEqual(expected) { | |
assert.equal(actual, expected); | |
}, | |
toBe(expected) { |